mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-09 18:51:38 +00:00
MRF: anti followbot: gracefully handle accounts without a display name
This commit is contained in:
parent
992145e64c
commit
e53a9fd15e
1 changed files with 9 additions and 3 deletions
|
@ -23,15 +23,21 @@ 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.
|
||||||
nick_score =
|
nick_score =
|
||||||
nickname
|
nickname
|
||||||
|> String.downcase()
|
|> String.downcase()
|
||||||
|> score_nickname()
|
|> score_nickname()
|
||||||
|
|
||||||
|
# displayname will either be a binary string or nil, if a displayname isn't set.
|
||||||
name_score =
|
name_score =
|
||||||
displayname
|
if is_binary(displayname) do
|
||||||
|> String.downcase()
|
displayname
|
||||||
|> score_displayname()
|
|> String.downcase()
|
||||||
|
|> score_displayname()
|
||||||
|
else
|
||||||
|
0.0
|
||||||
|
end
|
||||||
|
|
||||||
nick_score + name_score
|
nick_score + name_score
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue