- defp delist_message(message) do
- follower_collection = User.get_by_ap_id(message["actor"].follower_address)
+ defp delist_message(message, threshold) when threshold > 0 do
+ follower_collection = User.get_cached_by_ap_id(message["actor"]).follower_address
+ to = message["to"] || []
+ cc = message["cc"] || []
+
+ follower_collection? = Enum.member?(to ++ 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", [Pleroma.Constants.as_public()])
+
+ {:public, recipients} when recipients > threshold ->
+ message
+ |> Map.put("to", [])
+ |> Map.put("cc", [Pleroma.Constants.as_public()])
+
+ _ ->
+ message
+ end