|
|
@ -2,13 +2,17 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
|
|
|
|
@behaviour Pleroma.Web.ActivityPub.MRF
|
|
|
|
@behaviour Pleroma.Web.ActivityPub.MRF
|
|
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
@impl true
|
|
|
|
def filter(object) do
|
|
|
|
def filter(%{"type" => "Create"} = object) do
|
|
|
|
policy = Pleroma.Config.get(:mrf_hellthread)
|
|
|
|
threshold = Pleroma.Config.get([:mrf_hellthread, :threshold])
|
|
|
|
|
|
|
|
recipients = (object["to"] || []) ++ (object["cc"] || [])
|
|
|
|
|
|
|
|
|
|
|
|
if length(object["to"]) + length(object["cc"]) > Keyword.get(policy, :threshold) do
|
|
|
|
if length(recipients) > threshold do
|
|
|
|
{:reject, nil}
|
|
|
|
{:reject, nil}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{:ok, object}
|
|
|
|
{:ok, object}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
|
|
|
def filter(object), do: {:ok, object}
|
|
|
|
end
|
|
|
|
end
|
|
|
|