summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2020-04-12 20:26:35 -0500
committerAlex Gleason <alex@alexgleason.me>2020-04-12 20:26:35 -0500
commit9a3c74b244bce6097a8c6da99692bfc9973e1ec8 (patch)
tree0ec2d6770054d4e318877ad26976b1abb78daa60
parent7ee35eb9a6a55ef610eb02a04a33f67e5921cff3 (diff)
downloadpleroma-9a3c74b244bce6097a8c6da99692bfc9973e1ec8.tar.gz
pleroma-9a3c74b244bce6097a8c6da99692bfc9973e1ec8.zip
Always accept deletions through SimplePolicy
-rw-r--r--lib/pleroma/web/activity_pub/mrf/simple_policy.ex3
-rw-r--r--test/web/activity_pub/mrf/simple_policy_test.exs23
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
index 4edc007fd..b23f263f5 100644
--- a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
@@ -149,6 +149,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
defp check_banner_removal(_actor_info, object), do: {:ok, object}
@impl true
+ def filter(%{"type" => "Delete"} = object), do: {:ok, object}
+
+ @impl true
def filter(%{"actor" => actor} = object) do
actor_info = URI.parse(actor)
diff --git a/test/web/activity_pub/mrf/simple_policy_test.exs b/test/web/activity_pub/mrf/simple_policy_test.exs
index 91c24c2d9..eaa595706 100644
--- a/test/web/activity_pub/mrf/simple_policy_test.exs
+++ b/test/web/activity_pub/mrf/simple_policy_test.exs
@@ -258,6 +258,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
assert SimplePolicy.filter(remote_user) == {:reject, nil}
end
+
+ test "always accept deletions" do
+ Config.put([:mrf_simple, :reject], ["remote.instance"])
+
+ deletion_message = build_remote_deletion_message()
+
+ assert SimplePolicy.filter(deletion_message) == {:ok, deletion_message}
+ end
end
describe "when :accept" do
@@ -308,6 +316,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
assert SimplePolicy.filter(remote_user) == {:ok, remote_user}
end
+
+ test "always accept deletions" do
+ Config.put([:mrf_simple, :accept], ["non.matching.remote"])
+
+ deletion_message = build_remote_deletion_message()
+
+ assert SimplePolicy.filter(deletion_message) == {:ok, deletion_message}
+ end
end
describe "when :avatar_removal" do
@@ -408,4 +424,11 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
"type" => "Person"
}
end
+
+ defp build_remote_deletion_message do
+ %{
+ "type" => "Delete",
+ "actor" => "https://remote.instance/users/bob"
+ }
+ end
end