summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-06-17 15:32:42 -0500
committerAlex Gleason <alex@alexgleason.me>2021-06-17 15:32:42 -0500
commita704d5499c03cb5609ea38a5f2ef06095ced3ef3 (patch)
tree3afa1398c72d9333e972c3402c1c0d0fd652a589
parentc802c3055ef6c1f763d5df68f9e5308093f7d565 (diff)
NsfwApiPolicy: Fall back more generously when functions don't match
-rw-r--r--lib/pleroma/web/activity_pub/mrf/nsfw_api_policy.ex7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/mrf/nsfw_api_policy.ex b/lib/pleroma/web/activity_pub/mrf/nsfw_api_policy.ex
index a1560c584..920821f38 100644
--- a/lib/pleroma/web/activity_pub/mrf/nsfw_api_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/nsfw_api_policy.ex
@@ -92,6 +92,11 @@ defmodule Pleroma.Web.ActivityPub.MRF.NsfwApiPolicy do
check_url_nsfw(url)
end
+ def check_url_nsfw(url) do
+ threshold = Config.get([@policy, :threshold])
+ {:sfw, %{url: url, score: nil, threshold: threshold}}
+ end
+
def check_attachment_nsfw(%{"url" => urls} = attachment) when is_list(urls) do
if Enum.all?(urls, &match?({:sfw, _}, check_url_nsfw(&1))) do
{:sfw, attachment}
@@ -107,6 +112,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.NsfwApiPolicy do
end
end
+ def check_attachment_nsfw(attachment), do: {:sfw, attachment}
+
def check_object_nsfw(%{"attachment" => attachments} = object) when is_list(attachments) do
if Enum.all?(attachments, &match?({:sfw, _}, check_attachment_nsfw(&1))) do
{:sfw, object}