Merge branch 'feature/blocks-deny-refollow' into 'develop'

activitypub conformance: deny refollow for blocks

See merge request pleroma/pleroma!170
This commit is contained in:
lambda 2018-05-25 07:15:01 +00:00
commit 5d6d86bf00
2 changed files with 30 additions and 16 deletions

View File

@ -170,9 +170,14 @@ def register_changeset(struct, params \\ %{}) do
def follow(%User{} = follower, %User{info: info} = followed) do def follow(%User{} = follower, %User{info: info} = followed) do
ap_followers = followed.follower_address ap_followers = followed.follower_address
if following?(follower, followed) or info["deactivated"] do cond do
following?(follower, followed) or info["deactivated"] ->
{:error, "Could not follow user: #{followed.nickname} is already on your list."} {:error, "Could not follow user: #{followed.nickname} is already on your list."}
else
blocks?(followed, follower) ->
{:error, "Could not follow user: #{followed.nickname} blocked you."}
true ->
if !followed.local && follower.local && !ap_enabled?(followed) do if !followed.local && follower.local && !ap_enabled?(followed) do
Websub.subscribe(follower, followed) Websub.subscribe(follower, followed)
end end

View File

@ -46,6 +46,15 @@ test "can't follow a deactivated users" do
{:error, _} = User.follow(user, followed) {:error, _} = User.follow(user, followed)
end end
test "can't follow a user who blocked us" do
blocker = insert(:user)
blockee = insert(:user)
{:ok, blocker} = User.block(blocker, blockee)
{:error, _} = User.follow(blockee, blocker)
end
# This is a somewhat useless test. # This is a somewhat useless test.
# test "following a remote user will ensure a websub subscription is present" do # test "following a remote user will ensure a websub subscription is present" do
# user = insert(:user) # user = insert(:user)