2018-05-17 11:32:23 +02:00
|
|
|
defmodule EventosWeb.ActivityPub.ObjectView do
|
|
|
|
use EventosWeb, :view
|
2018-05-30 14:27:21 +02:00
|
|
|
alias EventosWeb.ActivityPub.ObjectView
|
2018-05-17 11:32:23 +02:00
|
|
|
alias Eventos.Service.ActivityPub.Transmogrifier
|
|
|
|
@base %{
|
|
|
|
"@context" => [
|
|
|
|
"https://www.w3.org/ns/activitystreams",
|
|
|
|
"https://w3id.org/security/v1",
|
|
|
|
%{
|
|
|
|
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
|
|
|
|
"sensitive" => "as:sensitive",
|
|
|
|
"Hashtag" => "as:Hashtag",
|
|
|
|
"toot" => "http://joinmastodon.org/ns#",
|
|
|
|
"Emoji" => "toot:Emoji"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
def render("event.json", %{event: event}) do
|
|
|
|
|
|
|
|
|
|
|
|
event = %{
|
|
|
|
"type" => "Event",
|
|
|
|
"id" => event.url,
|
|
|
|
"name" => event.title,
|
2018-05-30 14:27:21 +02:00
|
|
|
"category" => render_one(event.category, ObjectView, "category.json", as: :category),
|
2018-05-17 11:32:23 +02:00
|
|
|
"content" => event.description,
|
|
|
|
"mediaType" => "text/markdown",
|
|
|
|
"published" => Timex.format!(event.inserted_at, "{ISO:Extended}"),
|
|
|
|
"updated" => Timex.format!(event.updated_at, "{ISO:Extended}"),
|
|
|
|
}
|
|
|
|
Map.merge(event, @base)
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("category.json", %{category: category}) do
|
2018-05-30 14:27:21 +02:00
|
|
|
%{"title" => category.title}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("category.json", %{category: nil}) do
|
|
|
|
nil
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
end
|