From 0251690e96d683fb5f5eee11e2dfff4c008676cf Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 17 Apr 2018 20:35:07 -0400 Subject: [PATCH] Add federation for unrepeats --- lib/pleroma/web/activity_pub/activity_pub.ex | 4 +++- lib/pleroma/web/activity_pub/utils.ex | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index b3154ea99..2239da472 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -140,8 +140,10 @@ def announce( end end - def unannounce(%User{} = actor, %Object{} = object) do + def unannounce(%User{} = actor, %Object{} = object, local \\ true) do with %Activity{} = activity <- get_existing_announce(actor.ap_id, object), + unannounce_data <- make_unannounce_data(actor, activity), + {:ok, _unannounce_activity} <- insert(unannounce_data, local), {:ok, _activity} <- Repo.delete(activity), {:ok, object} <- remove_announce_from_object(activity, object) do {:ok, object} diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index a124bb8b6..9e2fa1fb2 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -283,15 +283,15 @@ def make_announce_data( """ def make_unannounce_data( %User{ap_id: ap_id} = user, - %Object{data: %{"id" => id}} = object + %Activity{data: %{"id" => id, "context" => context}} = activity ) do %{ "type" => "Undo", "actor" => ap_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"], - "context" => object.data["context"] + "context" => context } end