Fix unblock handling

This commit is contained in:
Francis Dinh 2018-05-21 05:00:58 -04:00
parent f2d6c3a512
commit cc5373b846
3 changed files with 8 additions and 6 deletions

View file

@ -270,6 +270,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
with %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked), with %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked),
%User{} = blocker <- User.get_or_fetch_by_ap_id(blocker), %User{} = blocker <- User.get_or_fetch_by_ap_id(blocker),
{:ok, activity} <- ActivityPub.unblock(blocker, blocked, id, false) do {:ok, activity} <- ActivityPub.unblock(blocker, blocked, id, false) do
User.unblock(blocker, blocked)
{:ok, activity} {:ok, activity}
else else
e -> :error e -> :error

View file

@ -26,8 +26,9 @@
"type": "Block", "type": "Block",
"object": "http://localtesting.pleroma.lol/users/lain", "object": "http://localtesting.pleroma.lol/users/lain",
"nickname": "lain", "nickname": "lain",
"id": "http://mastodon.example.org/users/admin#follows/2", "id": "http://mastodon.example.org/users/admin#blocks/2",
"actor": "http://mastodon.example.org/users/admin" "actor": "http://mastodon.example.org/users/admin"
}, },
"actor": "http://mastodon.example.org/users/admin" "actor": "http://mastodon.example.org/users/admin",
"id": "http://mastodon.example.org/users/admin#blocks/2/undo"
} }

View file

@ -316,7 +316,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
"http://mastodon.example.org/users/admin/statuses/99542391527669785/activity" "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity"
end end
test "it works for incomming unfollows" do test "it works for incomming unfollows with an existing follow" do
user = insert(:user) user = insert(:user)
follow_data = follow_data =
@ -360,7 +360,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert User.blocks?(blocker, user) assert User.blocks?(blocker, user)
end end
test "it works for incoming unblocks" do test "it works for incoming unblocks with an existing block" do
user = insert(:user) user = insert(:user)
block_data = block_data =
@ -379,11 +379,11 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert data["type"] == "Undo" assert data["type"] == "Undo"
assert data["object"]["type"] == "Block" assert data["object"]["type"] == "Block"
assert data["object"]["object"] == user.ap_id assert data["object"]["object"] == user.ap_id
assert data["actor"] == "https://mastodon.example.org/users/admin" assert data["actor"] == "http://mastodon.example.org/users/admin"
blocker = User.get_by_ap_id(data["actor"]) blocker = User.get_by_ap_id(data["actor"])
refute User.blocks?(blocker, user.ap_id) refute User.blocks?(blocker, user)
end end
end end