Side Effects: On undoing, put information about the undone object.
authorLain Soykaf <lain@soykaf.club>
Fri, 24 Jul 2020 12:40:22 +0000 (14:40 +0200)
committerLain Soykaf <lain@soykaf.club>
Fri, 24 Jul 2020 12:40:22 +0000 (14:40 +0200)
lib/pleroma/web/activity_pub/side_effects.ex
test/web/activity_pub/side_effects_test.exs

index 1d2c296a5c001a99d02c8ae72256d61029aa1dd4..33bee1576857536c19dd218b352c975a22347b0f 100644 (file)
@@ -174,6 +174,10 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
   def handle(%{data: %{"type" => "Undo", "object" => undone_object}} = object, meta) do
     with undone_object <- Activity.get_by_ap_id(undone_object),
          :ok <- handle_undoing(undone_object) do
+      meta =
+        meta
+        |> Keyword.put(:embedded_object, undone_object.data)
+
       {:ok, object, meta}
     end
   end
index 2649b060ab53f0881a4473670f50e64b83101b12..d48c235c03b790d3207332c14314e32376148619 100644 (file)
@@ -312,8 +312,13 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
       }
     end
 
-    test "deletes the original block", %{block_undo: block_undo, block: block} do
-      {:ok, _block_undo, _} = SideEffects.handle(block_undo)
+    test "deletes the original block, but sets `embedded_object`", %{
+      block_undo: block_undo,
+      block: block
+    } do
+      {:ok, _block_undo, meta} = SideEffects.handle(block_undo)
+
+      assert meta[:embedded_object] == block.data
       refute Activity.get_by_id(block.id)
     end