1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectView do
9 alias Pleroma.Web.ActivityPub.Transmogrifier
11 def render("object.json", %{object: %Object{} = object}) do
12 base = Pleroma.Web.ActivityPub.Utils.make_json_ld_header()
14 additional = Transmogrifier.prepare_object(object.data)
15 Map.merge(base, additional)
18 def render("object.json", %{object: %Activity{data: %{"type" => activity_type}} = activity})
19 when activity_type in ["Create"] do
20 base = Pleroma.Web.ActivityPub.Utils.make_json_ld_header()
21 object = Object.normalize(activity, fetch: false)
24 Transmogrifier.prepare_object(activity.data)
25 |> Map.put("object", Transmogrifier.prepare_object(object.data))
27 Map.merge(base, additional)
30 def render("object.json", %{object: %Activity{} = activity}) do
31 base = Pleroma.Web.ActivityPub.Utils.make_json_ld_header()
32 object_id = Object.normalize(activity, id_only: true)
35 Transmogrifier.prepare_object(activity.data)
36 |> Map.put("object", object_id)
38 Map.merge(base, additional)