add license boilerplate to pleroma core
[akkoma] / lib / pleroma / web / activity_pub / mrf / hellthread_policy.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
6 @behaviour Pleroma.Web.ActivityPub.MRF
7
8 @impl true
9 def filter(%{"type" => "Create"} = object) do
10 threshold = Pleroma.Config.get([:mrf_hellthread, :threshold])
11 recipients = (object["to"] || []) ++ (object["cc"] || [])
12
13 if length(recipients) > threshold do
14 {:reject, nil}
15 else
16 {:ok, object}
17 end
18 end
19
20 @impl true
21 def filter(object), do: {:ok, object}
22 end