Handle reopened reports with deleted statuses
[akkoma] / lib / pleroma / web / admin_api / views / report_view.ex
index ac25925dafd4442a12b394a9c67d5885827d81d3..13602efd9f4d9612b6f6787f3226e8f77c63a5a1 100644 (file)
@@ -4,6 +4,7 @@
 
 defmodule Pleroma.Web.AdminAPI.ReportView do
   use Pleroma.Web, :view
+  alias Pleroma.Activity
   alias Pleroma.HTML
   alias Pleroma.User
   alias Pleroma.Web.AdminAPI.Report
@@ -45,10 +46,16 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
   def render("index_grouped.json", %{groups: groups}) do
     reports =
       Enum.map(groups, fn group ->
+        status =
+          case group.status do
+            %Activity{} = activity -> StatusView.render("show.json", %{activity: activity})
+            _ -> group.status
+          end
+
         %{
           date: group[:date],
-          account: merge_account_views(group[:account]),
-          status: StatusView.render("show.json", %{activity: group[:status]}),
+          account: group[:account],
+          status: Map.put_new(status, "deleted", false),
           actors: Enum.map(group[:actors], &merge_account_views/1),
           reports:
             group[:reports]