diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-20 11:28:40 +0100 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-25 10:10:05 +0100 |
commit | 0c350b79395d6712c7c4fee649cdbd77aa4052cc (patch) | |
tree | 2899a67fbe65c29b84c35ab417dbec96913095c4 /app/services/notification_service.rb | |
parent | bf708e55c2e6035b64861a1cda8bfe3d3b4a2105 (diff) | |
download | gitlab-ce-0c350b79395d6712c7c4fee649cdbd77aa4052cc.tar.gz |
address comments
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r-- | app/services/notification_service.rb | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 2a467ade542..f74e6cac174 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -179,14 +179,14 @@ class NotificationService mentioned_users = note.mentioned_users - 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 + ability, subject = if note.for_personal_snippet? + [:read_personal_snippet, note.noteable] + else + [:read_project, note.project] + end + + mentioned_users.select! do |user| + user.can?(ability, subject) end # Add all users participating in the thread (author, assignee, comment authors) @@ -220,12 +220,7 @@ class NotificationService recipients.delete(note.author) recipients = recipients.uniq - # build notify method like 'note_commit_email' - 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 + notify_method = "note_#{note.to_ability_name}_email".to_sym recipients.each do |recipient| mailer.send(notify_method, recipient.id, note.id).deliver_later |