diff options
author | lambda <pleromagit@rogerbraun.net> | 2019-03-11 13:19:09 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2019-03-11 13:19:09 +0000 |
commit | 9df4fa22dd3b0944f65327d312aa24db76fc74e8 (patch) | |
tree | 94bf26e514d5b7f6569e4c2ec6206797bc8f8173 /lib/pleroma/web | |
parent | 0afab164428eb4284df128aaeab2945adf540fe5 (diff) | |
parent | 6038c8a753e289acd0c4a4268ca2b40479696704 (diff) | |
download | pleroma-9df4fa22dd3b0944f65327d312aa24db76fc74e8.tar.gz |
Merge branch 'broadcast-activity-id-on-deletion' into 'develop'
Broadcast proper deleted activity id to conform to MastoAPI streaming spec
See merge request pleroma/pleroma!917
Diffstat (limited to 'lib/pleroma/web')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 16 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/streamer.ex | 8 |
3 files changed, 17 insertions, 11 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index adb42b9ab..2f11f8984 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -311,14 +311,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do user = User.get_cached_by_ap_id(actor) to = object.data["to"] || [] ++ object.data["cc"] || [] - data = %{ - "type" => "Delete", - "actor" => actor, - "object" => id, - "to" => to - } - - with {:ok, _} <- Object.delete(object), + with {:ok, object, activity} <- Object.delete(object), + data <- %{ + "type" => "Delete", + "actor" => actor, + "object" => id, + "to" => to, + "deleted_activity_id" => activity && activity.id + }, {:ok, activity} <- insert(data, local), # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info {:ok, _actor} <- decrease_note_count_if_public(user, object), diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 88007aa16..27d223a3e 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -736,6 +736,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do def prepare_outgoing(%{"type" => _type} = data) do data = data + |> strip_internal_fields |> maybe_fix_object_url |> Map.merge(Utils.make_json_ld_header()) @@ -870,7 +871,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do "announcements", "announcement_count", "emoji", - "context_id" + "context_id", + "deleted_activity_id" ]) end diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 27e8020f4..ad888c361 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -211,15 +211,19 @@ defmodule Pleroma.Web.Streamer do end) end - def push_to_socket(topics, topic, %Activity{id: id, data: %{"type" => "Delete"}}) do + def push_to_socket(topics, topic, %Activity{ + data: %{"type" => "Delete", "deleted_activity_id" => deleted_activity_id} + }) do Enum.each(topics[topic] || [], fn socket -> send( socket.transport_pid, - {:text, %{event: "delete", payload: to_string(id)} |> Jason.encode!()} + {:text, %{event: "delete", payload: to_string(deleted_activity_id)} |> Jason.encode!()} ) end) end + def push_to_socket(_topics, _topic, %Activity{data: %{"type" => "Delete"}}), do: :noop + def push_to_socket(topics, topic, item) do Enum.each(topics[topic] || [], fn socket -> # Get the current user so we have up-to-date blocks etc. |