More tests

This commit is contained in:
Thomas Citharel
2018-08-24 11:34:00 +02:00
parent a3852f26c1
commit 686cf04787
29 changed files with 945 additions and 241 deletions

View File

@@ -134,10 +134,17 @@ defmodule EventosWeb.ActivityPub.ActorView do
else
"Announce"
end,
"actor" => activity.data.organizer_actor.url,
"actor" => activity.actor,
"published" => Timex.now(),
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
"object" => render_one(activity.data, ObjectView, "event.json", as: :event)
"object" =>
case activity.type do
:Event ->
render_one(activity.data, ObjectView, "event.json", as: :event)
:Comment ->
render_one(activity.data, ObjectView, "note.json", as: :note)
end
}
end

View File

@@ -32,6 +32,19 @@ defmodule EventosWeb.ActivityPub.ObjectView do
Map.merge(event, @base)
end
def render("note.json", %{note: note}) do
event = %{
"type" => "Note",
"id" => note.url,
"content" => note.text,
"mediaType" => "text/markdown",
"published" => Timex.format!(note.inserted_at, "{ISO:Extended}"),
"updated" => Timex.format!(note.updated_at, "{ISO:Extended}")
}
Map.merge(event, @base)
end
def render("category.json", %{category: category}) do
%{"title" => category.title}
end