1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-24 08:54:08 +00:00
mobilizon/lib/mobilizon_web/views/activity_pub/object_view.ex

50 lines
1.5 KiB
Elixir
Raw Normal View History

defmodule MobilizonWeb.ActivityPub.ObjectView do
use MobilizonWeb, :view
alias MobilizonWeb.ActivityPub.ObjectView
2018-11-12 08:05:31 +00:00
alias Mobilizon.Service.ActivityPub.Utils
def render("event.json", %{event: event}) do
event = %{
"type" => "Event",
"actor" => event["actor"],
"id" => event["id"],
"name" => event["title"],
"category" => render_one(event["category"], ObjectView, "category.json", as: :category),
"content" => event["summary"],
"mediaType" => "text/html"
# "published" => Timex.format!(event.inserted_at, "{ISO:Extended}"),
# "updated" => Timex.format!(event.updated_at, "{ISO:Extended}")
}
2018-11-12 08:05:31 +00:00
Map.merge(event, Utils.make_json_ld_header())
end
2018-11-12 08:05:31 +00:00
def render("comment.json", %{comment: comment}) do
comment = %{
"actor" => comment["actor"],
"uuid" => comment["uuid"],
2018-11-12 08:05:31 +00:00
# The activity should have attributedTo, not the comment itself
# "attributedTo" => comment.attributed_to,
2018-08-24 09:34:00 +00:00
"type" => "Note",
"id" => comment["id"],
"content" => comment["content"],
"mediaType" => "text/html"
# "published" => Timex.format!(comment.inserted_at, "{ISO:Extended}"),
# "updated" => Timex.format!(comment.updated_at, "{ISO:Extended}")
2018-08-24 09:34:00 +00:00
}
2018-11-12 08:05:31 +00:00
Map.merge(comment, Utils.make_json_ld_header())
2018-08-24 09:34:00 +00:00
end
def render("category.json", %{category: category}) when not is_nil(category) do
2018-11-12 08:05:31 +00:00
%{
"identifier" => category.id,
"name" => category.title
}
end
def render("category.json", %{category: _category}) do
nil
end
end