1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.AdminAPI.ReportView do
10 alias Pleroma.Web.CommonAPI.Utils
11 alias Pleroma.Web.MastodonAPI.StatusView
13 def render("index.json", %{reports: reports}) do
15 reports: render_many(reports, __MODULE__, "show.json", as: :report)
19 def render("show.json", %{report: report}) do
20 user = User.get_cached_by_ap_id(report.data["actor"])
21 created_at = Utils.to_masto_date(report.data["published"])
23 [account_ap_id | status_ap_ids] = report.data["object"]
24 account = User.get_cached_by_ap_id(account_ap_id)
27 unless is_nil(report.data["content"]) do
28 HTML.filter_tags(report.data["content"])
34 Enum.map(status_ap_ids, fn ap_id ->
35 Activity.get_by_ap_id_with_object(ap_id)
40 account: merge_account_views(account),
41 actor: merge_account_views(user),
43 created_at: created_at,
44 statuses: StatusView.render("index.json", %{activities: statuses, as: :activity}),
45 state: report.data["state"]
49 defp merge_account_views(%User{} = user) do
50 Pleroma.Web.MastodonAPI.AccountView.render("account.json", %{user: user})
51 |> Map.merge(Pleroma.Web.AdminAPI.AccountView.render("show.json", %{user: user}))
54 defp merge_account_views(_), do: %{}