2020-01-26 21:36:50 +01:00
|
|
|
defmodule Mobilizon.Web.ActivityPub.ObjectView do
|
|
|
|
use Mobilizon.Web, :view
|
2019-09-13 01:35:03 +02:00
|
|
|
|
2020-01-22 02:14:42 +01:00
|
|
|
alias Mobilizon.Federation.ActivityPub.{Activity, Utils}
|
2018-05-17 11:32:23 +02:00
|
|
|
|
2019-04-25 19:05:05 +02: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 11:32:23 +02:00
|
|
|
end
|