Fix handling report from a deactivated user
This commit is contained in:
parent
48e490cd58
commit
6e4de2383f
3 changed files with 23 additions and 1 deletions
1
changelog.d/handle-report-from-deactivated-user.fix
Normal file
1
changelog.d/handle-report-from-deactivated-user.fix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix handling report from a deactivated user
|
|
@ -583,7 +583,7 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_report_state(activity_id, state) do
|
def update_report_state(activity_id, state) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id(activity_id) do
|
with %Activity{} = activity <- Activity.get_by_id(activity_id, filter: []) do
|
||||||
Utils.update_report_state(activity, state)
|
Utils.update_report_state(activity, state)
|
||||||
else
|
else
|
||||||
nil -> {:error, :not_found}
|
nil -> {:error, :not_found}
|
||||||
|
|
|
@ -123,6 +123,7 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
reporter: reporter,
|
||||||
id: report_id,
|
id: report_id,
|
||||||
second_report_id: second_report_id
|
second_report_id: second_report_id
|
||||||
}
|
}
|
||||||
|
@ -266,6 +267,26 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
|
||||||
assert ModerationLog.get_log_entry_message(second_log_entry) ==
|
assert ModerationLog.get_log_entry_message(second_log_entry) ==
|
||||||
"@#{admin.nickname} updated report ##{second_report_id} (on user @#{second_activity.user_actor.nickname}) with 'closed' state"
|
"@#{admin.nickname} updated report ##{second_report_id} (on user @#{second_activity.user_actor.nickname}) with 'closed' state"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "works if reporter is deactivated", %{
|
||||||
|
conn: conn,
|
||||||
|
id: id,
|
||||||
|
reporter: reporter
|
||||||
|
} do
|
||||||
|
Pleroma.User.set_activation(reporter, false)
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> patch("/api/pleroma/admin/reports", %{
|
||||||
|
"reports" => [
|
||||||
|
%{"state" => "resolved", "id" => id}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|> json_response_and_validate_schema(:no_content)
|
||||||
|
|
||||||
|
activity = Activity.get_by_id_with_user_actor(id)
|
||||||
|
assert activity.data["state"] == "resolved"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/pleroma/admin/reports" do
|
describe "GET /api/pleroma/admin/reports" do
|
||||||
|
|
Loading…
Reference in a new issue