ActivityPub: Change addressing of Undo.

This commit is contained in:
lain 2019-10-04 16:32:42 +02:00 committed by Ariadne Conill
parent 4d38e48558
commit b7d2ca0372
2 changed files with 11 additions and 6 deletions

View file

@ -472,14 +472,16 @@ def make_announce_data(
"""
def make_unannounce_data(
%User{ap_id: ap_id} = user,
%Activity{data: %{"context" => context}} = activity,
%Activity{data: %{"context" => context, "object" => object}} = activity,
activity_id
) do
object = Object.normalize(object)
%{
"type" => "Undo",
"actor" => ap_id,
"object" => activity.data,
"to" => [user.follower_address, activity.data["actor"]],
"to" => [user.follower_address, object.data["actor"]],
"cc" => [Pleroma.Constants.as_public()],
"context" => context
}
@ -488,14 +490,16 @@ def make_unannounce_data(
def make_unlike_data(
%User{ap_id: ap_id} = user,
%Activity{data: %{"context" => context}} = activity,
%Activity{data: %{"context" => context, "object" => object}} = activity,
activity_id
) do
object = Object.normalize(object)
%{
"type" => "Undo",
"actor" => ap_id,
"object" => activity.data,
"to" => [user.follower_address, activity.data["actor"]],
"to" => [user.follower_address, object.data["actor"]],
"cc" => [Pleroma.Constants.as_public()],
"context" => context
}

View file

@ -760,10 +760,11 @@ test "unliking a previously liked object" do
{:ok, like_activity, object} = ActivityPub.like(user, object)
assert object.data["like_count"] == 1
{:ok, _, _, object} = ActivityPub.unlike(user, object)
{:ok, unlike_activity, _, object} = ActivityPub.unlike(user, object)
assert object.data["like_count"] == 0
assert Activity.get_by_id(like_activity.id) == nil
assert note_activity.actor in unlike_activity.recipients
end
end
@ -806,7 +807,7 @@ test "unannouncing a previously announced object" do
assert unannounce_activity.data["to"] == [
User.ap_followers(user),
announce_activity.data["actor"]
object.data["actor"]
]
assert unannounce_activity.data["type"] == "Undo"