commit: 48af6850fc2903d6f8c7cbf43b7db6b769c37a2a
parent 55612cb8ee4908a2fbb200ff581bb07c7e43410a
Author: Mint <mint@plagu.ee>
Date: Fri, 12 Apr 2024 23:04:37 +0300
RemoteReportPolicy: Fix third-party report detection
Diffstat:
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/lib/pleroma/web/activity_pub/mrf/remote_report_policy.ex b/lib/pleroma/web/activity_pub/mrf/remote_report_policy.ex
@@ -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}
diff --git a/test/pleroma/web/activity_pub/mrf/remote_report_policy_test.exs b/test/pleroma/web/activity_pub/mrf/remote_report_policy_test.exs
@@ -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)