Always accept deletions through SimplePolicy

This commit is contained in:
Alex Gleason 2020-04-12 20:26:35 -05:00
parent 7ee35eb9a6
commit 9a3c74b244
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 26 additions and 0 deletions

View file

@ -148,6 +148,9 @@ defp check_banner_removal(%{host: actor_host} = _actor_info, %{"image" => _image
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)

View file

@ -258,6 +258,14 @@ test "actor has a matching host" 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 @@ test "actor has a matching host" 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 @@ defp build_remote_user do
"type" => "Person"
}
end
defp build_remote_deletion_message do
%{
"type" => "Delete",
"actor" => "https://remote.instance/users/bob"
}
end
end