forked from mirrors/akkoma
MRF: anti followbot: gracefully handle accounts without a display name
This commit is contained in:
parent
992145e64c
commit
e53a9fd15e
|
@ -23,15 +23,21 @@ defp score_displayname("fedibot"), do: 1.0
|
|||
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.
|
||||
nick_score =
|
||||
nickname
|
||||
|> String.downcase()
|
||||
|> score_nickname()
|
||||
|
||||
# displayname will either be a binary string or nil, if a displayname isn't set.
|
||||
name_score =
|
||||
if is_binary(displayname) do
|
||||
displayname
|
||||
|> String.downcase()
|
||||
|> score_displayname()
|
||||
else
|
||||
0.0
|
||||
end
|
||||
|
||||
nick_score + name_score
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue