2018-10-11 15:37:39 +00:00
|
|
|
defmodule MobilizonWeb.ActivityPub.ObjectView do
|
|
|
|
use MobilizonWeb, :view
|
2018-11-12 08:05:31 +00:00
|
|
|
alias Mobilizon.Service.ActivityPub.Utils
|
2019-04-25 17:05:05 +00:00
|
|
|
alias Mobilizon.Activity
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2019-04-25 17:05:05 +00:00
|
|
|
def render("activity.json", %{activity: %Activity{local: local, data: data} = activity}) do
|
|
|
|
%{
|
|
|
|
"id" => data["id"],
|
|
|
|
"type" =>
|
|
|
|
if local do
|
|
|
|
"Create"
|
|
|
|
else
|
|
|
|
"Announce"
|
|
|
|
end,
|
|
|
|
"actor" => activity.actor,
|
|
|
|
# Not sure if needed since this is used into outbox
|
|
|
|
"published" => Timex.now(),
|
|
|
|
"to" => activity.recipients,
|
|
|
|
"object" =>
|
|
|
|
case data["type"] do
|
|
|
|
"Event" ->
|
|
|
|
render_one(data, ObjectView, "event.json", as: :event)
|
|
|
|
|
|
|
|
"Note" ->
|
|
|
|
render_one(data, ObjectView, "comment.json", as: :comment)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|> Map.merge(Utils.make_json_ld_header())
|
|
|
|
end
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|