commit: 717c5901f893527b059201d1ce7899060a18a1a5
parent 6f047cc308352cb3437f95e31e73487bba194abe
Author: tusooa <tusooa@kazv.moe>
Date: Wed, 9 Nov 2022 23:02:27 -0500
Render a generated reported activity properly
Diffstat:
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/lib/pleroma/web/admin_api/report.ex b/lib/pleroma/web/admin_api/report.ex
@@ -36,7 +36,9 @@ defmodule Pleroma.Web.AdminAPI.Report do
"to" => [],
"cc" => [],
"object" => act["id"],
- "published" => act["published"]
+ "published" => act["published"],
+ "id" => act["id"],
+ "context" => "pleroma:fake"
},
recipients: [user.ap_id],
object: %Object{
@@ -46,7 +48,9 @@ defmodule Pleroma.Web.AdminAPI.Report do
"content" => act["content"],
"published" => act["published"],
"to" => [],
- "cc" => []
+ "cc" => [],
+ "id" => act["id"],
+ "context" => "pleroma:fake"
}
}
}
diff --git a/test/pleroma/web/admin_api/controllers/report_controller_test.exs b/test/pleroma/web/admin_api/controllers/report_controller_test.exs
@@ -54,6 +54,32 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
assert notes["content"] == "this is an admin note"
end
+ test "renders reported content even if the status is deleted", %{conn: conn} do
+ [reporter, target_user] = insert_pair(:user)
+ activity = insert(:note_activity, user: target_user)
+ activity = Activity.normalize(activity)
+
+ {:ok, %{id: report_id}} =
+ CommonAPI.report(reporter, %{
+ account_id: target_user.id,
+ comment: "I feel offended",
+ status_ids: [activity.id]
+ })
+
+ CommonAPI.delete(activity.id, target_user)
+
+ response =
+ conn
+ |> get("/api/pleroma/admin/reports/#{report_id}")
+ |> json_response_and_validate_schema(:ok)
+
+ assert response["id"] == report_id
+
+ assert [status] = response["statuses"]
+ assert activity.data["id"] == status["uri"]
+ assert activity.object.data["content"] == status["content"]
+ end
+
test "returns 404 when report id is invalid", %{conn: conn} do
conn = get(conn, "/api/pleroma/admin/reports/test")