-
- def get_tombstone(%Activity{data: data}, deleted \\ DateTime.utc_now()) do
- %{
- id: data["id"],
- context: data["context"],
- type: "Tombstone",
- published: data["published"],
- deleted: deleted
- }
- end
-
- def swap_data_with_tombstone(activity) do
- with tombstone = get_tombstone(activity),
- Notification.clear(activity),
- {:ok, changed_activity} =
- activity
- |> change(%{data: tombstone})
- |> Repo.update() do
- {:ok, changed_activity}
- end
- end