logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

report_view.ex (1514B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.PleromaAPI.ReportView do
  5. use Pleroma.Web, :view
  6. alias Pleroma.HTML
  7. alias Pleroma.Web.AdminAPI.Report
  8. alias Pleroma.Web.CommonAPI.Utils
  9. alias Pleroma.Web.MastodonAPI.AccountView
  10. alias Pleroma.Web.MastodonAPI.StatusView
  11. def render("index.json", %{reports: reports, for: for_user}) do
  12. %{
  13. reports:
  14. reports[:items]
  15. |> Enum.map(&Report.extract_report_info/1)
  16. |> Enum.map(&render(__MODULE__, "show.json", Map.put(&1, :for, for_user))),
  17. total: reports[:total]
  18. }
  19. end
  20. def render("show.json", %{
  21. report: report,
  22. user: actor,
  23. account: account,
  24. statuses: statuses,
  25. for: for_user
  26. }) do
  27. created_at = Utils.to_masto_date(report.data["published"])
  28. content =
  29. unless is_nil(report.data["content"]) do
  30. HTML.filter_tags(report.data["content"])
  31. else
  32. nil
  33. end
  34. %{
  35. id: report.id,
  36. account: AccountView.render("show.json", %{user: account, for: for_user}),
  37. actor: AccountView.render("show.json", %{user: actor, for: for_user}),
  38. content: content,
  39. created_at: created_at,
  40. statuses:
  41. StatusView.render("index.json", %{
  42. activities: statuses,
  43. as: :activity,
  44. for: for_user
  45. }),
  46. state: report.data["state"]
  47. }
  48. end
  49. end