From 67ab5805536ed64ca842998bfd4b3b0e63d13dd3 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 24 Jun 2020 17:18:53 -0500 Subject: [PATCH] Filter outstanding follower requests from deactivated accounts --- lib/pleroma/following_relationship.ex | 1 + test/user_test.exs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/pleroma/following_relationship.ex b/lib/pleroma/following_relationship.ex index 093b1f405..c2020d30a 100644 --- a/lib/pleroma/following_relationship.ex +++ b/lib/pleroma/following_relationship.ex @@ -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 diff --git a/test/user_test.exs b/test/user_test.exs index 311b6c683..9b66f3f51 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -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) -- 2.45.2