Merge branch 'fix-close-reports' into 'develop'

Fix closing a report where the reporter is deactivated

Closes #133

See merge request soapbox-pub/rebased!219
This commit is contained in:
Alex Gleason 2022-11-27 18:34:37 +00:00
commit 7a14517763
2 changed files with 20 additions and 1 deletions

View file

@ -596,7 +596,7 @@ def update_report_state(activity_ids, state) when is_list(activity_ids) do
end
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, []) do
Utils.update_report_state(activity, state)
else
nil -> {:error, :not_found}

View file

@ -1204,6 +1204,25 @@ test "updates report state" do
assert activity_id == activity.data["id"]
end
test "update report state when the actor is deactivated" do
[reporter, target_user] = insert_pair(:user)
activity = insert(:note_activity, user: target_user)
{:ok, %Activity{id: report_id}} =
CommonAPI.report(reporter, %{
account_id: target_user.id,
comment: "I feel offended",
status_ids: [activity.id]
})
# Deactivate the reporter (and sanity-check it).
{:ok, reporter} = User.set_activation(reporter, false)
refute reporter.is_active
# We can still close the report.
{:ok, _report} = CommonAPI.update_report_state(report_id, "resolved")
end
test "updates report state, don't strip when report_strip_status is false" do
clear_config([:instance, :report_strip_status], false)