From efe962934661cd94edb1c24c6d34419cd28b82f9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 15 Apr 2015 15:53:23 +0200 Subject: Fix Mention notification level. --- app/services/notification_service.rb | 37 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'app') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 203e654c18f..ab5a653d5c0 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -130,22 +130,23 @@ class NotificationService if note.commit_id.present? recipients << note.commit_author end - - # Get users who left comment in thread - recipients = recipients.concat(noteable_commenters(note)) + + # Add all users participating in the thread (author, assignee, comment authors) + participants = + if target.is_a?(Commit) + author_ids = Note.for_commit_id(target.id).pluck(:author_id).uniq + User.where(id: author_ids) + else + target.participants + end + recipients = recipients.concat(participants) # Merge project watchers recipients = recipients.concat(project_watchers(note.project)).compact.uniq - # Reject users with Mention notification level - recipients = reject_mention_users(recipients, note.project) - - # Add explicitly mentioned users - if target.respond_to?(:participants) - recipients = recipients.concat(target.participants) - else - recipients = recipients.concat(note.mentioned_users) - end + # Reject users with Mention notification level, except those mentioned in _this_ note. + recipients = reject_mention_users(recipients - note.mentioned_users, note.project) + recipients = recipients + note.mentioned_users # Reject mutes users recipients = reject_muted_users(recipients, note.project) @@ -216,18 +217,6 @@ class NotificationService protected - def noteable_commenters(note) - opts = { noteable_type: note.noteable_type, project_id: note.project_id } - - if note.commit_id.present? - opts.merge!(commit_id: note.commit_id) - else - opts.merge!(noteable_id: note.noteable_id) - end - - User.where(id: Note.where(opts).pluck(:author_id)) - end - # Get project users with WATCH notification level def project_watchers(project) project_members = project_member_notification(project) -- cgit v1.2.1 From b73ffbd3cb7dd89f54351b74e0cf4d1df63f0310 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 15 Apr 2015 17:01:14 +0200 Subject: Fix for snippets. --- app/services/notification_service.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index ab5a653d5c0..cfed7964c37 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -133,11 +133,13 @@ class NotificationService # Add all users participating in the thread (author, assignee, comment authors) participants = - if target.is_a?(Commit) + if target.respond_to?(:participants) + target.participants + elsif target.is_a?(Commit) author_ids = Note.for_commit_id(target.id).pluck(:author_id).uniq User.where(id: author_ids) else - target.participants + note.mentioned_users end recipients = recipients.concat(participants) -- cgit v1.2.1