change the anti-link-spam MRF implementation to use old_user? instead of the previous name

This commit is contained in:
William Pitcock 2019-06-21 22:27:14 +00:00
parent 630ac6a921
commit 127a5a7d65

View file

@ -8,7 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
require Logger require Logger
# has the user successfully posted before? # has the user successfully posted before?
defp user_has_posted_before?(%User{} = u) do defp old_user?(%User{} = u) do
u.info.note_count > 0 || u.info.follower_count > 0 u.info.note_count > 0 || u.info.follower_count > 0
end end
@ -25,13 +25,13 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
def filter(%{"type" => "Create", "actor" => actor, "object" => object} = message) do def filter(%{"type" => "Create", "actor" => actor, "object" => object} = message) do
with {:ok, %User{} = u} <- User.get_or_fetch_by_ap_id(actor), with {:ok, %User{} = u} <- User.get_or_fetch_by_ap_id(actor),
{:contains_links, true} <- {:contains_links, contains_links?(object)}, {:contains_links, true} <- {:contains_links, contains_links?(object)},
{:posted_before, true} <- {:posted_before, user_has_posted_before?(u)} do {:old_user, true} <- {:old_user, old_user?(u)} do
{:ok, message} {:ok, message}
else else
{:contains_links, false} -> {:contains_links, false} ->
{:ok, message} {:ok, message}
{:posted_before, false} -> {:old_user, false} ->
{:reject, nil} {:reject, nil}
{:error, _} -> {:error, _} ->