Fix AntiFollowbotPolicy when trying to follow a relay

This commit is contained in:
feld 2019-08-30 00:38:03 +00:00 committed by kaniini
parent d9d7765383
commit 7853b3f17d
2 changed files with 9 additions and 4 deletions

View File

@ -49,6 +49,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Reverse Proxy limiting `max_body_length` was incorrectly defined and only checked `Content-Length` headers which may not be sufficient in some circumstances - Reverse Proxy limiting `max_body_length` was incorrectly defined and only checked `Content-Length` headers which may not be sufficient in some circumstances
- MRF: fix use of unserializable keyword lists in describe() implementations - MRF: fix use of unserializable keyword lists in describe() implementations
- ActivityPub: Deactivated user deletion - ActivityPub: Deactivated user deletion
- MRF: fix ability to follow a relay when AntiFollowbotPolicy was enabled
### Added ### Added
- Expiring/ephemeral activites. All activities can have expires_at value set, which controls when they should be deleted automatically. - Expiring/ephemeral activites. All activities can have expires_at value set, which controls when they should be deleted automatically.

View File

@ -25,11 +25,15 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
defp score_displayname(_), do: 0.0 defp score_displayname(_), do: 0.0
defp determine_if_followbot(%User{nickname: nickname, name: displayname}) do 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 = nick_score =
if is_binary(nickname) do
nickname nickname
|> String.downcase() |> String.downcase()
|> score_nickname() |> score_nickname()
else
0.0
end
# displayname will either be a binary string or nil, if a displayname isn't set. # displayname will either be a binary string or nil, if a displayname isn't set.
name_score = name_score =