Filter outstanding follower requests from deactivated accounts
authorMark Felder <feld@FreeBSD.org>
Wed, 24 Jun 2020 22:18:53 +0000 (17:18 -0500)
committerMark Felder <feld@FreeBSD.org>
Wed, 24 Jun 2020 22:18:53 +0000 (17:18 -0500)
lib/pleroma/following_relationship.ex
test/user_test.exs

index 093b1f4050d62a94f70c865bc27262f2cb70b6ca..c2020d30a876a9169682f8271861d9e808165bf2 100644 (file)
@@ -124,6 +124,7 @@ defmodule Pleroma.FollowingRelationship do
     |> join(:inner, [r], f in assoc(r, :follower))
     |> where([r], r.state == ^:follow_pending)
     |> where([r], r.following_id == ^id)
+    |> where([r, f], f.deactivated != true)
     |> select([r, f], f)
     |> Repo.all()
   end
index 311b6c68300a11d7880e79fdbf49577f30a67dcd..9b66f3f51db7cb2672b6f6680b59b26a0c3234ad 100644 (file)
@@ -199,6 +199,16 @@ defmodule Pleroma.UserTest do
     assert [^pending_follower] = User.get_follow_requests(locked)
   end
 
+  test "doesn't return follow requests for deactivated accounts" do
+    locked = insert(:user, locked: true)
+    pending_follower = insert(:user, %{deactivated: true})
+
+    CommonAPI.follow(pending_follower, locked)
+
+    assert true == pending_follower.deactivated
+    assert [] = User.get_follow_requests(locked)
+  end
+
   test "clears follow requests when requester is blocked" do
     followed = insert(:user, locked: true)
     follower = insert(:user)