From 3d13fb05f851d127d852ee9c26afa4dab61410ad Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Fri, 24 Jul 2020 14:40:22 +0200 Subject: [PATCH] Side Effects: On undoing, put information about the undone object. --- lib/pleroma/web/activity_pub/side_effects.ex | 4 ++++ test/web/activity_pub/side_effects_test.exs | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex index 1d2c296a5..33bee1576 100644 --- a/lib/pleroma/web/activity_pub/side_effects.ex +++ b/lib/pleroma/web/activity_pub/side_effects.ex @@ -174,6 +174,10 @@ def handle(%{data: %{"type" => "Announce"}} = object, meta) 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 diff --git a/test/web/activity_pub/side_effects_test.exs b/test/web/activity_pub/side_effects_test.exs index 2649b060a..d48c235c0 100644 --- a/test/web/activity_pub/side_effects_test.exs +++ b/test/web/activity_pub/side_effects_test.exs @@ -312,8 +312,13 @@ test "when activation is required", %{delete: delete, user: user} 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