From 717c5901f893527b059201d1ce7899060a18a1a5 Mon Sep 17 00:00:00 2001 From: tusooa Date: Wed, 9 Nov 2022 23:02:27 -0500 Subject: [PATCH] Render a generated reported activity properly --- lib/pleroma/web/admin_api/report.ex | 8 ++++-- .../controllers/report_controller_test.exs | 26 +++++++++++++++++++ 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 index f377e1804..6856bfcb3 100644 --- a/lib/pleroma/web/admin_api/report.ex +++ b/lib/pleroma/web/admin_api/report.ex @@ -36,7 +36,9 @@ defp make_fake_activity(act, user) 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 @@ defp make_fake_activity(act, user) 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 index 30dcb87e2..164cbb95b 100644 --- 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 @@ test "returns report by its id", %{conn: conn} 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")