RemoteReportPolicy: Fix third-party report detection

This commit is contained in:
Mint 2024-04-12 23:04:37 +03:00 committed by b
parent 55612cb8ee
commit 48af6850fc
2 changed files with 15 additions and 2 deletions

View file

@ -47,7 +47,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.RemoteReportPolicy do
end
with true <- Config.get([:mrf_remote_report, :reject_third_party]),
String.starts_with?(to, Pleroma.Web.Endpoint.url()) do
false <- String.starts_with?(to, Pleroma.Web.Endpoint.url()) do
{:reject, "[RemoteReportPolicy] Third-party: #{to}"}
else
_ -> {:ok, object}

View file

@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.RemoteReportPolicyTest do
assert {:ok, _} = RemoteReportPolicy.filter(activity)
end
test "rejects report on third-party if `reject_third_party: true`" do
test "rejects report on third party if `reject_third_party: true`" do
clear_config([:mrf_remote_report, :reject_third_party], true)
clear_config([:mrf_remote_report, :reject_empty_message], false)
@ -59,6 +59,19 @@ defmodule Pleroma.Web.ActivityPub.MRF.RemoteReportPolicyTest do
assert {:reject, _} = RemoteReportPolicy.filter(activity)
end
test "preserves report on first party if `reject_third_party: true`" do
clear_config([:mrf_remote_report, :reject_third_party], true)
clear_config([:mrf_remote_report, :reject_empty_message], false)
activity = %{
"type" => "Flag",
"actor" => "https://mastodon.social/users/Gargron",
"object" => ["http://localhost:4001/actor"]
}
assert {:ok, _} = RemoteReportPolicy.filter(activity)
end
test "preserves report on third party if `reject_third_party: false`" do
clear_config([:mrf_remote_report, :reject_third_party], false)
clear_config([:mrf_remote_report, :reject_empty_message], false)