From 8d8cb08f94490299bfc7fe97381a34e4a7a095a9 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 27 Feb 2019 14:51:07 +0100 Subject: [PATCH 1/2] Add follow request test. --- test/user_test.exs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/user_test.exs b/test/user_test.exs index 0b1c39ecf..cbe4693fc 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -50,6 +50,20 @@ test "ap_followers returns the followers collection for the user" 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) From b24cc44e8d1e1b29cdeb916f192e30303a55ff5d Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 27 Feb 2019 15:01:54 +0100 Subject: [PATCH 2/2] Follower requests: Utilize object index. Closes #677 --- lib/pleroma/user.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 01d532ab3..c5085fa82 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -613,9 +613,10 @@ def get_follow_requests_query(%User{} = user) do ), where: fragment( - "? @> ?", + "coalesce((?)->'object'->>'id', (?)->>'object') = ?", a.data, - ^%{"object" => user.ap_id} + a.data, + ^user.ap_id ) ) end