X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fanti_followbot_policy.ex;h=0270b96ae06c5cb8a8727cc0c76b0430022c90ae;hb=396bc69aeef951f163c0c20474ce4653df1dd667;hp=34665a3a6999491b1ff3847bab127031e5f513c8;hpb=4e72762322a5616ce426df62888ee3bc7af19dc8;p=akkoma
diff --git a/lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex b/lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
index 34665a3a6..0270b96ae 100644
--- a/lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
@@ -1,10 +1,12 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
alias Pleroma.User
+ @moduledoc "Prevent followbots from following with a bit of heuristic"
+
@behaviour Pleroma.Web.ActivityPub.MRF
# XXX: this should become User.normalize_by_ap_id() or similar, really.
@@ -23,11 +25,15 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
defp score_displayname(_), do: 0.0
defp determine_if_followbot(%User{nickname: nickname, name: displayname}) do
- # nickname will always be a binary string because it's generated by Pleroma.
+ # nickname will be a binary string except when following a relay
nick_score =
- nickname
- |> String.downcase()
- |> score_nickname()
+ if is_binary(nickname) do
+ nickname
+ |> String.downcase()
+ |> score_nickname()
+ else
+ 0.0
+ end
# displayname will either be a binary string or nil, if a displayname isn't set.
name_score =
@@ -60,4 +66,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
@impl true
def filter(message), do: {:ok, message}
+
+ @impl true
+ def describe, do: {:ok, %{}}
end