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
9 alias Pleroma.Web.AdminAPI.Report
10 alias Pleroma.Web.CommonAPI.Utils
11 alias Pleroma.Web.MastodonAPI.StatusView
13 def render("index.json", %{reports: reports}) do
17 |> Enum.map(&Report.extract_report_info(&1))
18 |> Enum.map(&render(__MODULE__, "show.json", &1))
20 total: reports[:total]
24 def render("show.json", %{report: report, user: user, account: account, statuses: statuses}) do
25 created_at = Utils.to_masto_date(report.data["published"])
28 unless is_nil(report.data["content"]) do
29 HTML.filter_tags(report.data["content"])
36 account: merge_account_views(account),
37 actor: merge_account_views(user),
39 created_at: created_at,
40 statuses: StatusView.render("index.json", %{activities: statuses, as: :activity}),
41 state: report.data["state"]
45 defp merge_account_views(%User{} = user) do
46 Pleroma.Web.MastodonAPI.AccountView.render("show.json", %{user: user})
47 |> Map.merge(Pleroma.Web.AdminAPI.AccountView.render("show.json", %{user: user}))
50 defp merge_account_views(_), do: %{}