I don’t want to make anything too complex.
I was looking through some of the code for this (thanks @tshenry for the link), and it doesn’t seem like it needs to be that complicated.
The group mentions are currently being triggered here (L78-80). The expand_group_mentions() function is a generator responsible for spitting out the users who should get group mention notifications (while respecting policies like the SiteSetting.max_users_notified_per_group_mention).
That seems like a natural place to put this logic.
In the create_notification function, we suppress notifications for anyone who has already received a notification of the same type. This is why editing a post with a group mention triggers a notification for new group members – a notification is actually generated for all users in the group, but it is then suppressed for people who already got the notification.
I’m suggesting something similar, by updating the expand_group_mentions() function to also filter out groups that have a record in the group_mentions table.
Something like (please excuse my lack of knowledge about ruby syntax)
def expand_group_mentions(groups, post)
return unless post.user && groups
Group.mentionable(post.user, include_public: false).where(id: groups.map(&:id)).each do |group|
next if group.user_count >= SiteSetting.max_users_notified_per_group_mention
# Add check for groups already mentioned
next if GroupMentions().where(group_id: group.id, post_id: post.id).length > 0
yield group, group.users
end
end
This does not do anything for the JIT warning though.
Trying to help solve this, let me know if I’m just being annoying… ![]()