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.ReportView do
10 alias Pleroma.Web.AdminAPI
11 alias Pleroma.Web.AdminAPI.Report
12 alias Pleroma.Web.CommonAPI.Utils
13 alias Pleroma.Web.MastodonAPI.StatusView
15 defdelegate merge_account_views(user), to: AdminAPI.AccountView
17 def render("index.json", %{reports: reports}) do
21 |> Enum.map(&Report.extract_report_info/1)
22 |> Enum.map(&render(__MODULE__, "show.json", &1))
24 total: reports[:total]
28 def render("show.json", %{report: report, user: user, account: account, statuses: statuses}) do
29 created_at = Utils.to_masto_date(report.data["published"])
32 unless is_nil(report.data["content"]) do
33 HTML.filter_tags(report.data["content"])
40 account: merge_account_views(account),
41 actor: merge_account_views(user),
43 created_at: created_at,
45 StatusView.render("index.json", %{
49 state: report.data["state"],
50 notes: render(__MODULE__, "index_notes.json", %{notes: report.report_notes})
54 def render("index_notes.json", %{notes: notes}) when is_list(notes) do
55 Enum.map(notes, &render(__MODULE__, "show_note.json", &1))
58 def render("index_notes.json", _), do: []
60 def render("show_note.json", %{
64 inserted_at: inserted_at
66 user = User.get_by_id(user_id)
71 user: merge_account_views(user),
72 created_at: Utils.to_masto_date(inserted_at)