Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-01-20 13:28:40 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-01-25 12:10:05 +0300
commit0c350b79395d6712c7c4fee649cdbd77aa4052cc (patch)
tree2899a67fbe65c29b84c35ab417dbec96913095c4 /app/services/notification_service.rb
parentbf708e55c2e6035b64861a1cda8bfe3d3b4a2105 (diff)
address comments
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r--app/services/notification_service.rb23
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