Merge branch 'fix/following-request-from-deactivated' into 'develop'
Filter outstanding follower requests from deactivated accounts Closes #1771 See merge request pleroma/pleroma!2682
This commit is contained in:
commit
0e26ef2ab9
2 changed files with 11 additions and 0 deletions
|
@ -124,6 +124,7 @@ def get_follow_requests(%User{id: id}) do
|
||||||
|> join(:inner, [r], f in assoc(r, :follower))
|
|> join(:inner, [r], f in assoc(r, :follower))
|
||||||
|> where([r], r.state == ^:follow_pending)
|
|> where([r], r.state == ^:follow_pending)
|
||||||
|> where([r], r.following_id == ^id)
|
|> where([r], r.following_id == ^id)
|
||||||
|
|> where([r, f], f.deactivated != true)
|
||||||
|> select([r, f], f)
|
|> select([r, f], f)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
|
@ -199,6 +199,16 @@ test "doesn't return already accepted or duplicate follow requests" do
|
||||||
assert [^pending_follower] = User.get_follow_requests(locked)
|
assert [^pending_follower] = User.get_follow_requests(locked)
|
||||||
end
|
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
|
test "clears follow requests when requester is blocked" do
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
Loading…
Reference in a new issue