diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-05 14:36:06 +0100 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-18 18:38:17 -0500 |
commit | d6b11dafd37e78c12c982c42f274928293cdfa53 (patch) | |
tree | e20c62bc3b11b77e366bce2251146d5f5ec86e0c /app/services/notification_service.rb | |
parent | 270dc22658424ee7f279db99e56c6fc69acd3eb7 (diff) | |
download | gitlab-ce-d6b11dafd37e78c12c982c42f274928293cdfa53.tar.gz |
Support notes without project
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r-- | app/services/notification_service.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index c3b61e68eab..2a467ade542 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -178,8 +178,15 @@ class NotificationService recipients = [] mentioned_users = note.mentioned_users - mentioned_users.select! do |user| - user.can?(:read_project, note.project) + + if note.for_personal_snippet? + mentioned_users.select! do |user| + user.can?(:read_personal_snippet, note.noteable) + end + else + mentioned_users.select! do |user| + user.can?(:read_project, note.project) + end end # Add all users participating in the thread (author, assignee, comment authors) @@ -192,11 +199,13 @@ class NotificationService recipients = recipients.concat(participants) - # Merge project watchers - recipients = add_project_watchers(recipients, note.project) + unless note.for_personal_snippet? + # Merge project watchers + recipients = add_project_watchers(recipients, note.project) - # Merge project with custom notification - recipients = add_custom_notifications(recipients, note.project, :new_note) + # Merge project with custom notification + recipients = add_custom_notifications(recipients, note.project, :new_note) + end # Reject users with Mention notification level, except those mentioned in _this_ note. recipients = reject_mention_users(recipients - mentioned_users, note.project) @@ -212,7 +221,11 @@ class NotificationService recipients = recipients.uniq # build notify method like 'note_commit_email' - notify_method = "note_#{note.noteable_type.underscore}_email".to_sym + if note.for_personal_snippet? + notify_method = "note_personal_snippet_email".to_sym + else + notify_method = "note_#{note.noteable_type.underscore}_email".to_sym + end recipients.each do |recipient| mailer.send(notify_method, recipient.id, note.id).deliver_later |