Commit 089e2588 authored by kaniini's avatar kaniini

Merge branch 'speedup-follow-requests' into 'develop'

Speedup follow requests

Closes #677

See merge request pleroma/pleroma!871
parents 3c849d04 b24cc44e
......@@ -613,9 +613,10 @@ defmodule Pleroma.User do
),
where:
fragment(
"? @> ?",
"coalesce((?)->'object'->>'id', (?)->>'object') = ?",
a.data,
^%{"object" => user.ap_id}
a.data,
^user.ap_id
)
)
end
......
......@@ -50,6 +50,20 @@ defmodule Pleroma.UserTest do
assert expected_followers_collection == User.ap_followers(user)
end
test "returns all pending follow requests" do
unlocked = insert(:user)
locked = insert(:user, %{info: %{locked: true}})
follower = insert(:user)
Pleroma.Web.TwitterAPI.TwitterAPI.follow(follower, %{"user_id" => unlocked.id})
Pleroma.Web.TwitterAPI.TwitterAPI.follow(follower, %{"user_id" => locked.id})
assert {:ok, []} = User.get_follow_requests(unlocked)
assert {:ok, [activity]} = User.get_follow_requests(locked)
assert activity
end
test "follow_all follows mutliple users" do
user = insert(:user)
followed_zero = insert(:user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment