summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2022-11-09 23:02:27 -0500
committertusooa <tusooa@kazv.moe>2022-11-09 23:02:27 -0500
commit717c5901f893527b059201d1ce7899060a18a1a5 (patch)
tree4d0f22c86089f4c31c6e20541a386ccfb703bd64
parent6f047cc308352cb3437f95e31e73487bba194abe (diff)
Render a generated reported activity properly
-rw-r--r--lib/pleroma/web/admin_api/report.ex8
-rw-r--r--test/pleroma/web/admin_api/controllers/report_controller_test.exs26
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 @@ 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
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 @@ 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")