spc-pleroma/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex

19 lines
453 B
Elixir
Raw Normal View History

2018-12-22 22:18:31 +00:00
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
@behaviour Pleroma.Web.ActivityPub.MRF
@impl true
2018-12-23 11:24:53 +00:00
def filter(%{"type" => "Create"} = object) do
threshold = Pleroma.Config.get([:mrf_hellthread, :threshold])
recipients = (object["to"] || []) ++ (object["cc"] || [])
2018-12-22 22:18:31 +00:00
2018-12-23 11:24:53 +00:00
if length(recipients) > threshold do
2018-12-22 22:18:31 +00:00
{:reject, nil}
else
{:ok, object}
end
end
2018-12-23 11:24:53 +00:00
@impl true
def filter(object), do: {:ok, object}
2018-12-22 22:32:38 +00:00
end