1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 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)),
23 total: reports[:total]
27 def render("show.json", %{report: report, user: user, account: account, statuses: statuses}) do
28 created_at = Utils.to_masto_date(report.data["published"])
31 unless is_nil(report.data["content"]) do
32 HTML.filter_tags(report.data["content"])
39 account: merge_account_views(account),
40 actor: merge_account_views(user),
42 created_at: created_at,
44 StatusView.render("index.json", %{
48 state: report.data["state"],
49 notes: render(__MODULE__, "index_notes.json", %{notes: report.report_notes})
53 def render("index_notes.json", %{notes: notes}) when is_list(notes) do
54 Enum.map(notes, &render(__MODULE__, "show_note.json", Map.from_struct(&1)))
57 def render("index_notes.json", _), do: []
59 def render("show_note.json", %{
63 inserted_at: inserted_at
65 user = User.get_by_id(user_id)
70 user: merge_account_views(user),
71 created_at: Utils.to_masto_date(inserted_at)