+ # For Announce activities, we filter the recipients based on following status for any actors
+ # that match actual users. See issue #164 for more information about why this is necessary.
+ defp get_recipients(%{"type" => "Announce"} = data) do
+ to = data["to"] || []
+ cc = data["cc"] || []
+ recipients = to ++ cc
+ actor = User.get_cached_by_ap_id(data["actor"])
+
+ recipients
+ |> Enum.filter(fn recipient ->
+ case User.get_cached_by_ap_id(recipient) do
+ nil ->
+ true
+
+ user ->
+ User.following?(user, actor)
+ end
+ end)
+
+ {recipients, to, cc}
+ end
+
+ defp get_recipients(data) do
+ to = data["to"] || []
+ cc = data["cc"] || []
+ recipients = to ++ cc
+ {recipients, to, cc}