+ else
+ {:ok, message}
+ end
+ end
+ end
+
+ defp reject_message(message, _threshold), do: {:ok, message}
+
+ defp get_recipient_count(message) do
+ recipients = (message["to"] || []) ++ (message["cc"] || [])
+ follower_collection = User.get_cached_by_ap_id(message["actor"]).follower_address
+
+ if Enum.member?(recipients, "https://www.w3.org/ns/activitystreams#Public") do
+ recipients =
+ recipients
+ |> List.delete("https://www.w3.org/ns/activitystreams#Public")
+ |> List.delete(follower_collection)
+
+ {:public, length(recipients)}
+ else
+ recipients =
+ recipients
+ |> List.delete(follower_collection)
+
+ {:not_public, length(recipients)}
+ end
+ end
+
+ @impl true
+ def filter(%{"type" => "Create"} = message) do
+ reject_threshold =
+ Pleroma.Config.get(
+ [:mrf_hellthread, :reject_threshold],
+ Pleroma.Config.get([:mrf_hellthread, :threshold])
+ )
+
+ delist_threshold = Pleroma.Config.get([:mrf_hellthread, :delist_threshold])