the system.
"""
+ alias Pleroma.Activity
alias Pleroma.EctoType.ActivityPub.ObjectValidators
alias Pleroma.Object
alias Pleroma.User
|> UndoValidator.cast_and_validate()
|> Ecto.Changeset.apply_action(:insert) do
object = stringify_keys(object)
+ undone_object = Activity.get_by_ap_id(object["object"])
+
+ meta =
+ meta
+ |> Keyword.put(:object_data, undone_object.data)
+
{:ok, object, meta}
end
end
if !do_not_federate && local do
activity =
- if object = Keyword.get(meta, :embedded_object) do
+ if object = Keyword.get(meta, :object_data) do
%{activity | data: Map.put(activity.data, "object", object)}
else
activity
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
:ok
end
- test "when given an `embedded_object` in meta, Federation will receive a the original activity with the `object` field set to this embedded object" do
+ test "when given an `object_data` in meta, Federation will receive a the original activity with the `object` field set to this embedded object" do
activity = insert(:note_activity)
object = %{"id" => "1", "type" => "Love"}
- meta = [local: true, embedded_object: object]
+ meta = [local: true, object_data: object]
activity_with_object = %{activity | data: Map.put(activity.data, "object", object)}
}
end
- test "deletes the original block, but sets `embedded_object`", %{
+ test "deletes the original block", %{
block_undo: block_undo,
block: block
} do
- {:ok, _block_undo, meta} = SideEffects.handle(block_undo)
+ {:ok, _block_undo, _meta} = SideEffects.handle(block_undo)
- assert meta[:embedded_object] == block.data
refute Activity.get_by_id(block.id)
end