Use correct activity for undo
This commit is contained in:
parent
4b9f2ab526
commit
f0798440de
@ -142,7 +142,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
|
|
||||||
def unannounce(%User{} = actor, %Object{} = object, local \\ true) do
|
def unannounce(%User{} = actor, %Object{} = object, local \\ true) do
|
||||||
with %Activity{} = activity <- get_existing_announce(actor.ap_id, object),
|
with %Activity{} = activity <- get_existing_announce(actor.ap_id, object),
|
||||||
unannounce_data <- make_unannounce_data(actor, object),
|
unannounce_data <- make_unannounce_data(actor, activity),
|
||||||
{:ok, unannounce_activity} <- insert(unannounce_data, local),
|
{:ok, unannounce_activity} <- insert(unannounce_data, local),
|
||||||
:ok <- maybe_federate(activity),
|
:ok <- maybe_federate(activity),
|
||||||
{:ok, _activity} <- Repo.delete(activity),
|
{:ok, _activity} <- Repo.delete(activity),
|
||||||
|
@ -283,13 +283,13 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||||||
"""
|
"""
|
||||||
def make_unannounce_data(
|
def make_unannounce_data(
|
||||||
%User{ap_id: ap_id} = user,
|
%User{ap_id: ap_id} = user,
|
||||||
%Object{data: %{"id" => id, "context" => context}} = object
|
%Activity{data: %{"id" => id, "context" => context}} = activity
|
||||||
) do
|
) do
|
||||||
%{
|
%{
|
||||||
"type" => "Undo",
|
"type" => "Undo",
|
||||||
"actor" => ap_id,
|
"actor" => ap_id,
|
||||||
"object" => id,
|
"object" => id,
|
||||||
"to" => [user.follower_address, object.data["actor"]],
|
"to" => [user.follower_address, activity.data["actor"]],
|
||||||
"cc" => ["https://www.w3.org/ns/activitystreams#Public"],
|
"cc" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"context" => context
|
"context" => context
|
||||||
}
|
}
|
||||||
|
@ -291,12 +291,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
|
|
||||||
assert unannounce_activity.data["to"] == [
|
assert unannounce_activity.data["to"] == [
|
||||||
User.ap_followers(user),
|
User.ap_followers(user),
|
||||||
note_activity.data["actor"]
|
announce_activity.data["actor"]
|
||||||
]
|
]
|
||||||
assert unannounce_activity.data["type"] == "Undo"
|
assert unannounce_activity.data["type"] == "Undo"
|
||||||
assert unannounce_activity.data["object"] == object.data["id"]
|
assert unannounce_activity.data["object"] == announce_activity.data["id"]
|
||||||
assert unannounce_activity.data["actor"] == user.ap_id
|
assert unannounce_activity.data["actor"] == user.ap_id
|
||||||
assert unannounce_activity.data["context"] == object.data["context"]
|
assert unannounce_activity.data["context"] == announce_activity.data["context"]
|
||||||
|
|
||||||
assert Repo.get(Activity, announce_activity.id) == nil
|
assert Repo.get(Activity, announce_activity.id) == nil
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user