v2 Suggestions: return `is_suggested` through the API
[akkoma] / lib / pleroma / web / admin_api / views / report_view.ex
index 215e311008fc8c081e461cd8737066341cee8b1c..1c67b2458369c4e9752954be8c859a57d31d560d 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.AdminAPI.ReportView do
@@ -10,16 +10,16 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
   alias Pleroma.Web.AdminAPI
   alias Pleroma.Web.AdminAPI.Report
   alias Pleroma.Web.CommonAPI.Utils
-  alias Pleroma.Web.MastodonAPI
   alias Pleroma.Web.MastodonAPI.StatusView
 
+  defdelegate merge_account_views(user), to: AdminAPI.AccountView
+
   def render("index.json", %{reports: reports}) do
     %{
       reports:
         reports[:items]
-        |> Enum.map(&Report.extract_report_info(&1))
-        |> Enum.map(&render(__MODULE__, "show.json", &1))
-        |> Enum.reverse(),
+        |> Enum.map(&Report.extract_report_info/1)
+        |> Enum.map(&render(__MODULE__, "show.json", &1)),
       total: reports[:total]
     }
   end
@@ -51,7 +51,7 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
   end
 
   def render("index_notes.json", %{notes: notes}) when is_list(notes) do
-    Enum.map(notes, &render(__MODULE__, "show_note.json", &1))
+    Enum.map(notes, &render(__MODULE__, "show_note.json", Map.from_struct(&1)))
   end
 
   def render("index_notes.json", _), do: []
@@ -71,11 +71,4 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
       created_at: Utils.to_masto_date(inserted_at)
     }
   end
-
-  defp merge_account_views(%User{} = user) do
-    MastodonAPI.AccountView.render("show.json", %{user: user, skip_relationships: true})
-    |> Map.merge(AdminAPI.AccountView.render("show.json", %{user: user}))
-  end
-
-  defp merge_account_views(_), do: %{}
 end