forked from AkkomaGang/akkoma
Side Effects: On undoing, put information about the undone object.
This commit is contained in:
parent
91f3cf9bc6
commit
3d13fb05f8
2 changed files with 11 additions and 2 deletions
|
@ -174,6 +174,10 @@ def handle(%{data: %{"type" => "Announce"}} = object, meta) do
|
||||||
def handle(%{data: %{"type" => "Undo", "object" => undone_object}} = object, meta) do
|
def handle(%{data: %{"type" => "Undo", "object" => undone_object}} = object, meta) do
|
||||||
with undone_object <- Activity.get_by_ap_id(undone_object),
|
with undone_object <- Activity.get_by_ap_id(undone_object),
|
||||||
:ok <- handle_undoing(undone_object) do
|
:ok <- handle_undoing(undone_object) do
|
||||||
|
meta =
|
||||||
|
meta
|
||||||
|
|> Keyword.put(:embedded_object, undone_object.data)
|
||||||
|
|
||||||
{:ok, object, meta}
|
{:ok, object, meta}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -312,8 +312,13 @@ test "when activation is required", %{delete: delete, user: user} do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "deletes the original block", %{block_undo: block_undo, block: block} do
|
test "deletes the original block, but sets `embedded_object`", %{
|
||||||
{:ok, _block_undo, _} = SideEffects.handle(block_undo)
|
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)
|
refute Activity.get_by_id(block.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue