From 446c5f00ab5bac55a10e0dcc37b939bd11194592 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 16 Nov 2021 11:56:15 +0100 Subject: [PATCH] Add "formerType" and "delete" attributes on Tombstones objects Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/types/actors.ex | 2 ++ lib/federation/activity_pub/types/comments.ex | 2 ++ lib/federation/activity_pub/types/discussions.ex | 2 ++ lib/federation/activity_pub/types/events.ex | 2 ++ lib/federation/activity_pub/types/posts.ex | 2 ++ lib/federation/activity_pub/types/resources.ex | 5 ++++- lib/federation/activity_pub/types/todo_lists.ex | 2 ++ lib/federation/activity_pub/types/todos.ex | 2 ++ 8 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/federation/activity_pub/types/actors.ex b/lib/federation/activity_pub/types/actors.ex index b08cccd4..77385067 100644 --- a/lib/federation/activity_pub/types/actors.ex +++ b/lib/federation/activity_pub/types/actors.ex @@ -98,6 +98,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Actors do "actor" => actor_url, "object" => %{ "type" => "Tombstone", + "formerType" => to_string(type), + "deleted" => DateTime.utc_now(), "id" => target_actor_url }, "id" => target_actor_url <> "/delete", diff --git a/lib/federation/activity_pub/types/comments.ex b/lib/federation/activity_pub/types/comments.ex index e510a537..fbdd58a8 100644 --- a/lib/federation/activity_pub/types/comments.ex +++ b/lib/federation/activity_pub/types/comments.ex @@ -84,6 +84,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Comments do "actor" => actor.url, "object" => %{ "type" => "Tombstone", + "formerType" => "Note", + "deleted" => DateTime.utc_now(), "id" => url }, "id" => url <> "/delete", diff --git a/lib/federation/activity_pub/types/discussions.ex b/lib/federation/activity_pub/types/discussions.ex index 2644fb7e..f1a30a12 100644 --- a/lib/federation/activity_pub/types/discussions.ex +++ b/lib/federation/activity_pub/types/discussions.ex @@ -117,6 +117,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Discussions do "actor" => actor.url, "object" => %{ "type" => "Tombstone", + "formerType" => "Note", + "deleted" => DateTime.utc_now(), "url" => url }, "id" => url <> "/delete", diff --git a/lib/federation/activity_pub/types/events.ex b/lib/federation/activity_pub/types/events.ex index f9ec1f13..3b18912e 100644 --- a/lib/federation/activity_pub/types/events.ex +++ b/lib/federation/activity_pub/types/events.ex @@ -84,6 +84,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Events do "actor" => actor.url, "object" => %{ "type" => "Tombstone", + "formerType" => "Event", + "deleted" => DateTime.utc_now(), "id" => url }, "to" => [actor.url <> "/followers", "https://www.w3.org/ns/activitystreams#Public"], diff --git a/lib/federation/activity_pub/types/posts.ex b/lib/federation/activity_pub/types/posts.ex index ed7642fb..07345994 100644 --- a/lib/federation/activity_pub/types/posts.ex +++ b/lib/federation/activity_pub/types/posts.ex @@ -79,6 +79,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Posts do "type" => "Delete", "object" => %{ "type" => "Tombstone", + "formerType" => "Article", + "deleted" => DateTime.utc_now(), "id" => url }, "id" => url <> "/delete", diff --git a/lib/federation/activity_pub/types/resources.ex b/lib/federation/activity_pub/types/resources.ex index a6d96592..f38d2c8a 100644 --- a/lib/federation/activity_pub/types/resources.ex +++ b/lib/federation/activity_pub/types/resources.ex @@ -150,7 +150,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Resources do @spec delete(Resource.t(), Actor.t(), boolean, map()) :: {:ok, ActivityStream.t(), Actor.t(), Resource.t()} | {:error, Ecto.Changeset.t()} def delete( - %Resource{url: url, actor: %Actor{url: group_url, members_url: members_url}} = resource, + %Resource{url: url, type: type, actor: %Actor{url: group_url, members_url: members_url}} = + resource, %Actor{url: actor_url} = actor, _local, _additionnal @@ -163,6 +164,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Resources do "type" => "Delete", "object" => %{ "type" => "Tombstone", + "formerType" => if(type == :folder, do: "ResourceCollection", else: "Document"), + "deleted" => DateTime.utc_now(), "id" => url }, "id" => url <> "/delete", diff --git a/lib/federation/activity_pub/types/todo_lists.ex b/lib/federation/activity_pub/types/todo_lists.ex index c0b288af..7202038a 100644 --- a/lib/federation/activity_pub/types/todo_lists.ex +++ b/lib/federation/activity_pub/types/todo_lists.ex @@ -57,6 +57,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.TodoLists do "type" => "Delete", "object" => %{ "type" => "Tombstone", + "formerType" => "TodoList", + "deleted" => DateTime.utc_now(), "id" => url }, "id" => url <> "/delete", diff --git a/lib/federation/activity_pub/types/todos.ex b/lib/federation/activity_pub/types/todos.ex index 0e97835e..5c8d3457 100644 --- a/lib/federation/activity_pub/types/todos.ex +++ b/lib/federation/activity_pub/types/todos.ex @@ -97,6 +97,8 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Todos do "type" => "Delete", "object" => %{ "type" => "Tombstone", + "formerType" => "Todo", + "deleted" => DateTime.utc_now(), "id" => url }, "id" => "#{url}/delete",