Prepare all types objects before serialising

Activities returned from inbox can include other types of objects like
Article
This commit is contained in:
sxsdv1 2019-01-12 17:52:30 +01:00
commit 1eb7318831
3 changed files with 41 additions and 1 deletions

View file

@ -57,6 +57,11 @@ defmodule Pleroma.Factory do
%Pleroma.Object{data: Map.merge(data, %{"to" => [user2.ap_id]})}
end
def article_factory do
note_factory()
|> Map.put("type", "Article")
end
def tombstone_factory do
data = %{
"type" => "Tombstone",
@ -110,6 +115,26 @@ defmodule Pleroma.Factory do
}
end
def article_activity_factory do
article = insert(:article)
data = %{
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
"type" => "Create",
"actor" => article.data["actor"],
"to" => article.data["to"],
"object" => article.data,
"published" => DateTime.utc_now() |> DateTime.to_iso8601(),
"context" => article.data["context"]
}
%Pleroma.Activity{
data: data,
actor: data["actor"],
recipients: data["to"]
}
end
def announce_activity_factory do
note_activity = insert(:note_activity)
user = insert(:user)