X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fhellthread_policy.ex;h=a3f516ae7fde83b0680c7ec6f9f98ad8c9a72a3c;hb=9af798ad40aa0fdd8c34155140a2caa2a1000d0c;hp=d5aa2b988254dc3837d3894f0a9c6ee5a4f30605;hpb=c76179419d5d4bb2423496856ad931974b56d6d5;p=akkoma diff --git a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex index d5aa2b988..a3f516ae7 100644 --- a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex @@ -1,14 +1,22 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do @behaviour Pleroma.Web.ActivityPub.MRF @impl true - def filter(object) do - policy = Pleroma.Config.get(:mrf_hellthread) + def filter(%{"type" => "Create"} = object) do + 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} else {:ok, object} end end + + @impl true + def filter(object), do: {:ok, object} end