Broadcast deleted activity id on deletion to conform to MastoAPI streamig spec
[akkoma] / lib / pleroma / web / activity_pub / activity_pub.ex
index 783491b67c7950ecd78f07880b22c986572f5c80..2f11f8984a1063db622dd96ace6a9dbb75576459 100644 (file)
@@ -309,15 +309,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ true) do
     user = User.get_cached_by_ap_id(actor)
+    to = object.data["to"] || [] ++ object.data["cc"] || []
 
-    data = %{
-      "type" => "Delete",
-      "actor" => actor,
-      "object" => id,
-      "to" => [user.follower_address, "https://www.w3.org/ns/activitystreams#Public"]
-    }
-
-    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),