1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
7 @behaviour Pleroma.Web.ActivityPub.MRF
9 defp delist_message(message) do
10 follower_collection = User.get_cached_by_ap_id(message["actor"]).follower_address
13 |> Map.put("to", [follower_collection])
14 |> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"])
18 def filter(%{"type" => "Create"} = message) do
19 delist_threshold = Pleroma.Config.get([:mrf_hellthread, :delist_threshold])
23 [:mrf_hellthread, :reject_threshold],
24 Pleroma.Config.get([:mrf_hellthread, :threshold])
27 recipients = (message["to"] || []) ++ (message["cc"] || [])
30 length(recipients) > reject_threshold and reject_threshold > 0 ->
33 length(recipients) > delist_threshold and delist_threshold > 0 ->
34 if Enum.member?(message["to"], "https://www.w3.org/ns/activitystreams#Public") or
35 Enum.member?(message["cc"], "https://www.w3.org/ns/activitystreams#Public") do
36 {:ok, delist_message(message)}
47 def filter(message), do: {:ok_notcreate, message}