Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into fine_grained_moderation_privileges
This commit is contained in:
commit
d5d4c7c11d
6 changed files with 82 additions and 12 deletions
|
|
@ -57,6 +57,16 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||
|
||||
assert SimplePolicy.filter(local_message) == {:ok, local_message}
|
||||
end
|
||||
|
||||
test "works with Updates" do
|
||||
clear_config([:mrf_simple, :media_removal], [{"remote.instance", "Some reason"}])
|
||||
media_message = build_media_message(type: "Update")
|
||||
|
||||
assert SimplePolicy.filter(media_message) ==
|
||||
{:ok,
|
||||
media_message
|
||||
|> Map.put("object", Map.delete(media_message["object"], "attachment"))}
|
||||
end
|
||||
end
|
||||
|
||||
describe "when :media_nsfw" do
|
||||
|
|
@ -90,12 +100,20 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||
|
||||
assert SimplePolicy.filter(local_message) == {:ok, local_message}
|
||||
end
|
||||
|
||||
test "works with Updates" do
|
||||
clear_config([:mrf_simple, :media_nsfw], [{"remote.instance", "Whetever"}])
|
||||
media_message = build_media_message(type: "Update")
|
||||
|
||||
assert SimplePolicy.filter(media_message) ==
|
||||
{:ok, put_in(media_message, ["object", "sensitive"], true)}
|
||||
end
|
||||
end
|
||||
|
||||
defp build_media_message do
|
||||
defp build_media_message(opts \\ []) do
|
||||
%{
|
||||
"actor" => "https://remote.instance/users/bob",
|
||||
"type" => "Create",
|
||||
"type" => opts[:type] || "Create",
|
||||
"object" => %{
|
||||
"attachment" => [%{}],
|
||||
"tag" => ["foo"],
|
||||
|
|
|
|||
|
|
@ -99,6 +99,24 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicyTest do
|
|||
|
||||
assert TagPolicy.filter(message) == {:ok, except_message}
|
||||
end
|
||||
|
||||
test "removes attachments in Updates" do
|
||||
actor = insert(:user, tags: ["mrf_tag:media-strip"])
|
||||
|
||||
message = %{
|
||||
"actor" => actor.ap_id,
|
||||
"type" => "Update",
|
||||
"object" => %{"attachment" => ["file1"]}
|
||||
}
|
||||
|
||||
except_message = %{
|
||||
"actor" => actor.ap_id,
|
||||
"type" => "Update",
|
||||
"object" => %{}
|
||||
}
|
||||
|
||||
assert TagPolicy.filter(message) == {:ok, except_message}
|
||||
end
|
||||
end
|
||||
|
||||
describe "mrf_tag:media-force-nsfw" do
|
||||
|
|
@ -119,5 +137,23 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicyTest do
|
|||
|
||||
assert TagPolicy.filter(message) == {:ok, except_message}
|
||||
end
|
||||
|
||||
test "Mark as sensitive on presence of attachments in Updates" do
|
||||
actor = insert(:user, tags: ["mrf_tag:media-force-nsfw"])
|
||||
|
||||
message = %{
|
||||
"actor" => actor.ap_id,
|
||||
"type" => "Update",
|
||||
"object" => %{"tag" => ["test"], "attachment" => ["file1"]}
|
||||
}
|
||||
|
||||
except_message = %{
|
||||
"actor" => actor.ap_id,
|
||||
"type" => "Update",
|
||||
"object" => %{"tag" => ["test"], "attachment" => ["file1"], "sensitive" => true}
|
||||
}
|
||||
|
||||
assert TagPolicy.filter(message) == {:ok, except_message}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue