diff options
| author | Douwe Maan <douwe@gitlab.com> | 2016-06-13 11:52:39 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2016-06-13 11:52:39 +0000 |
| commit | c03f12590440c4071151d0097299c3f3dd50c5c7 (patch) | |
| tree | c2a562e1dd53d19f3a9b685496213b646e1461b5 /app/services | |
| parent | 65df6bcb898e067e380658431136b5ef9aaba3b0 (diff) | |
| parent | 39ead205de72461e86db07525922f2fab5fff2a9 (diff) | |
| download | gitlab-ce-c03f12590440c4071151d0097299c3f3dd50c5c7.tar.gz | |
Merge branch 'issue_3359_2' into 'master'
Remove notification level from user model
part of #3359
See merge request !4494
Diffstat (limited to 'app/services')
| -rw-r--r-- | app/services/notification_service.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 91ca82ed3b7..875a3f4fab6 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -279,10 +279,11 @@ class NotificationService end def users_with_global_level_watch(ids) - User.where( - id: ids, - notification_level: NotificationSetting.levels[:watch] - ).pluck(:id) + NotificationSetting.where( + user_id: ids, + source_type: nil, + level: NotificationSetting.levels[:watch] + ).pluck(:user_id) end # Build a list of users based on project notifcation settings @@ -352,7 +353,9 @@ class NotificationService users = users.reject(&:blocked?) users.reject do |user| - next user.notification_level == level unless project + global_notification_setting = user.global_notification_setting + + next global_notification_setting.level == level unless project setting = user.notification_settings_for(project) @@ -361,13 +364,13 @@ class NotificationService end # reject users who globally set mention notification and has no setting per project/group - next user.notification_level == level unless setting + next global_notification_setting.level == level unless setting # reject users who set mention notification in project next true if setting.level == level # reject users who have mention level in project and disabled in global settings - setting.global? && user.notification_level == level + setting.global? && global_notification_setting.level == level end end @@ -456,7 +459,6 @@ class NotificationService def build_recipients(target, project, current_user, action: nil, previous_assignee: nil) recipients = target.participants(current_user) - recipients = add_project_watchers(recipients, project) recipients = reject_mention_users(recipients, project) |
