- @impl true
- def filter(%{"type" => "Create"} = object) do
- delist_threshold = Pleroma.Config.get([:mrf_hellthread, :delist_threshold])
- reject_threshold = Pleroma.Config.get([:mrf_hellthread, :reject_threshold])
- recipients = (object["to"] || []) ++ (object["cc"] || [])
+ defp delist_message(message, threshold) when threshold > 0 do
+ follower_collection = User.get_cached_by_ap_id(message["actor"]).follower_address
+
+ follower_collection? = Enum.member?(message["to"] ++ message["cc"], follower_collection)
+
+ message =
+ case get_recipient_count(message) do
+ {:public, recipients}
+ when follower_collection? and recipients > threshold ->
+ message
+ |> Map.put("to", [follower_collection])
+ |> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"])
+
+ {:public, recipients} when recipients > threshold ->
+ message
+ |> Map.put("to", [])
+ |> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"])