logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 00b39dea5d33a4595af1b63148b39c2bf335d4bc
parent 755279e25370a2363ce767c5df16eedee4e9526f
Author: lain <lain@soykaf.club>
Date:   Thu,  9 Feb 2023 19:52:01 +0000

Merge branch 'tusooa/3059-report-fake-create-render' into 'develop'

Fix inproper content being cached in report content

Closes #3059

See merge request pleroma/pleroma!3836

Diffstat:

Mlib/pleroma/web/admin_api/report.ex2+-
Mtest/pleroma/web/admin_api/controllers/report_controller_test.exs28++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/web/admin_api/report.ex b/lib/pleroma/web/admin_api/report.ex @@ -31,7 +31,7 @@ defmodule Pleroma.Web.AdminAPI.Report do defp make_fake_activity(act, user) do %Activity{ - id: "pleroma:fake", + id: "pleroma:fake:#{act["id"]}", data: %{ "actor" => user.ap_id, "type" => "Create", diff --git a/test/pleroma/web/admin_api/controllers/report_controller_test.exs b/test/pleroma/web/admin_api/controllers/report_controller_test.exs @@ -366,6 +366,34 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do |> json_response_and_validate_schema(:ok) end + test "renders content correctly", %{conn: conn} do + [reporter, target_user] = insert_pair(:user) + note = insert(:note, user: target_user, data: %{"content" => "mew 1"}) + note2 = insert(:note, user: target_user, data: %{"content" => "mew 2"}) + activity = insert(:note_activity, user: target_user, note: note) + activity2 = insert(:note_activity, user: target_user, note: note2) + + {:ok, _report} = + CommonAPI.report(reporter, %{ + account_id: target_user.id, + comment: "I feel offended", + status_ids: [activity.id, activity2.id] + }) + + CommonAPI.delete(activity.id, target_user) + CommonAPI.delete(activity2.id, target_user) + + response = + conn + |> get(report_path(conn, :index)) + |> json_response_and_validate_schema(:ok) + + assert [open_report] = response["reports"] + assert %{"statuses" => [s1, s2]} = open_report + assert "mew 1" in [s1["content"], s2["content"]] + assert "mew 2" in [s1["content"], s2["content"]] + end + test "returns 403 when requested by a non-admin" do user = insert(:user) token = insert(:oauth_token, user: user)