- when type in ["Create", "Like", "Announce", "Follow", "Move", "EmojiReaction"] do
- []
- |> Utils.maybe_notify_to_recipients(activity)
- |> Utils.maybe_notify_mentioned_recipients(activity)
- |> Utils.maybe_notify_subscribers(activity)
- |> Utils.maybe_notify_followers(activity)
- |> Enum.uniq()
- |> User.get_users_from_set(local_only)
+ when type in ["Create", "Like", "Announce", "Follow", "Move", "EmojiReact"] do
+ potential_receiver_ap_ids =
+ []
+ |> Utils.maybe_notify_to_recipients(activity)
+ |> Utils.maybe_notify_mentioned_recipients(activity)
+ |> Utils.maybe_notify_subscribers(activity)
+ |> Utils.maybe_notify_followers(activity)
+ |> Enum.uniq()
+
+ # Since even subscribers and followers can mute / thread-mute, filtering all above AP IDs
+ notification_enabled_ap_ids =
+ potential_receiver_ap_ids
+ |> exclude_relationship_restricted_ap_ids(activity)
+ |> exclude_thread_muter_ap_ids(activity)
+
+ potential_receivers =
+ potential_receiver_ap_ids
+ |> Enum.uniq()
+ |> User.get_users_from_set(local_only)
+
+ notification_enabled_users =
+ Enum.filter(potential_receivers, fn u -> u.ap_id in notification_enabled_ap_ids end)
+
+ {notification_enabled_users, potential_receivers -- notification_enabled_users}