1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.AdminAPI.StatusView do
8 require Pleroma.Constants
12 def render("index.json", opts) do
13 safe_render_many(opts.activities, __MODULE__, "show.json", opts)
16 def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
17 user = get_user(activity.data["actor"])
19 Pleroma.Web.MastodonAPI.StatusView.render("show.json", opts)
20 |> Map.merge(%{account: merge_account_views(user)})
23 defp merge_account_views(%User{} = user) do
24 Pleroma.Web.MastodonAPI.AccountView.render("show.json", %{user: user})
25 |> Map.merge(Pleroma.Web.AdminAPI.AccountView.render("show.json", %{user: user}))
28 defp merge_account_views(_), do: %{}
30 defp get_user(ap_id) do
32 user = User.get_cached_by_ap_id(ap_id) ->
35 user = User.get_by_guessed_nickname(ap_id) ->
39 User.error_user(ap_id)