diff options
author | Francis Dinh <normandy@firemail.cc> | 2018-04-17 04:13:08 -0400 |
---|---|---|
committer | Francis Dinh <normandy@firemail.cc> | 2018-04-17 04:13:08 -0400 |
commit | c9e7b984d5d09f6b1ecdeb04e888b9000de6e11c (patch) | |
tree | 58bfcfcca7aa8c1c11fed0be80d02a1d0b42ddea | |
parent | 85bd191291fdf0fb5f1807b3aa95913a607ddc6a (diff) | |
download | pleroma-c9e7b984d5d09f6b1ecdeb04e888b9000de6e11c.tar.gz |
Add make_unannounce_data helper function
-rw-r--r-- | lib/pleroma/web/activity_pub/utils.ex | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 6a36a6c10..a124bb8b6 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -237,7 +237,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do #### Announce-related helpers @doc """ - Retruns an existing announce activity if the notice has already been announced + Retruns an existing announce activity if the notice has already been announced """ def get_existing_announce(actor, %{data: %{"id" => id}}) do query = @@ -278,6 +278,23 @@ defmodule Pleroma.Web.ActivityPub.Utils do if activity_id, do: Map.put(data, "id", activity_id), else: data end + @doc """ + Make unannounce activity data for the given actor and object + """ + def make_unannounce_data( + %User{ap_id: ap_id} = user, + %Object{data: %{"id" => id}} = object + ) do + %{ + "type" => "Undo", + "actor" => ap_id, + "object" => id, + "to" => [user.follower_address, object.data["actor"]], + "cc" => ["https://www.w3.org/ns/activitystreams#Public"], + "context" => object.data["context"] + } + end + def add_announce_to_object(%Activity{data: %{"actor" => actor}}, object) do with announcements <- [actor | object.data["announcements"] || []] |> Enum.uniq() do update_element_in_object("announcement", announcements, object) |