X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fforce_bot_unlisted_policy.ex;h=51dbb1ad446cfd63e796ddb1ece2766e9b3e8c08;hb=250e2020987b1fc65251ba9564e41b38ba060391;hp=31fd90586a9500bfc5bc36868a9259c92fefa42e;hpb=699224a900d54b6d32e0bd3f2abd9eccc523df11;p=akkoma
diff --git a/lib/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy.ex b/lib/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy.ex
index 31fd90586..51dbb1ad4 100644
--- a/lib/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/force_bot_unlisted_policy.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy do
@@ -9,28 +9,23 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy do
require Pleroma.Constants
- defp check_by_actor_type(user) do
- if user.actor_type in ["Application", "Service"], do: 1.0, else: 0.0
- end
-
- defp check_by_nickname(user) do
- if Regex.match?(~r/bot@|ebooks@/i, user.nickname), do: 1.0, else: 0.0
- end
+ defp check_by_actor_type(user), do: user.actor_type in ["Application", "Service"]
+ defp check_by_nickname(user), do: Regex.match?(~r/bot@|ebooks@/i, user.nickname)
- defp botness_score(user), do: check_by_actor_type(user) + check_by_nickname(user)
+ defp check_if_bot(user), do: check_by_actor_type(user) or check_by_nickname(user)
@impl true
def filter(
- %{
- "type" => "Create",
- "to" => to,
- "cc" => cc,
- "actor" => actor,
- "object" => object
- } = message
- ) do
+ %{
+ "type" => "Create",
+ "to" => to,
+ "cc" => cc,
+ "actor" => actor,
+ "object" => object
+ } = message
+ ) do
user = User.get_cached_by_ap_id(actor)
- isbot = 0.8 < botness_score(user)
+ isbot = check_if_bot(user)
if isbot and Enum.member?(to, Pleroma.Constants.as_public()) do
to = List.delete(to, Pleroma.Constants.as_public()) ++ [user.follower_address]