Merge branch 'fix/bugfix-blocked-user-follow-reqs' into 'develop'

Clear follow requests when blocking a user

See merge request pleroma/pleroma!1583
This commit is contained in:
kaniini 2019-08-18 21:59:22 +00:00
commit 475fcb3e6c
2 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,7 @@ defmodule Pleroma.User do
alias Pleroma.Web alias Pleroma.Web
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils
alias Pleroma.Web.OAuth alias Pleroma.Web.OAuth
alias Pleroma.Web.OStatus alias Pleroma.Web.OStatus
@ -914,6 +915,13 @@ def block(blocker, %User{ap_id: ap_id} = blocked) do
blocker blocker
end end
# clear any requested follows as well
blocked =
case CommonAPI.reject_follow_request(blocked, blocker) do
{:ok, %User{} = updated_blocked} -> updated_blocked
nil -> blocked
end
blocker = blocker =
if subscribed_to?(blocked, blocker) do if subscribed_to?(blocked, blocker) do
{:ok, blocker} = unsubscribe(blocked, blocker) {:ok, blocker} = unsubscribe(blocked, blocker)

View File

@ -90,6 +90,17 @@ test "doesn't return already accepted or duplicate follow requests" do
assert activity assert activity
end end
test "clears follow requests when requester is blocked" do
followed = insert(:user, %{info: %{locked: true}})
follower = insert(:user)
CommonAPI.follow(follower, followed)
assert {:ok, [_activity]} = User.get_follow_requests(followed)
{:ok, _follower} = User.block(followed, follower)
assert {:ok, []} = User.get_follow_requests(followed)
end
test "follow_all follows mutliple users" do test "follow_all follows mutliple users" do
user = insert(:user) user = insert(:user)
followed_zero = insert(:user) followed_zero = insert(:user)