diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 15:10:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 15:10:36 +0000 |
commit | be4b3134a282f7a8812306777abd2d3150deecdc (patch) | |
tree | 0563327ce590b415047686c6feff43496742b49a /app/services/notification_recipients | |
parent | 998adcc422d4161515bf2960ef4dce71258f69a3 (diff) | |
download | gitlab-ce-be4b3134a282f7a8812306777abd2d3150deecdc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/notification_recipients')
-rw-r--r-- | app/services/notification_recipients/builder/base.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/services/notification_recipients/builder/base.rb b/app/services/notification_recipients/builder/base.rb index b41b969ad7c..d902ff5f565 100644 --- a/app/services/notification_recipients/builder/base.rb +++ b/app/services/notification_recipients/builder/base.rb @@ -172,6 +172,8 @@ module NotificationRecipients # Get project users with WATCH notification level # rubocop: disable CodeReuse/ActiveRecord def project_watchers + return new_project_watchers if Feature.enabled?(:notification_setting_recipient_refactor, project) + project_members_ids = user_ids_notifiable_on(project) user_ids_with_project_global = user_ids_notifiable_on(project, :global) @@ -184,16 +186,38 @@ module NotificationRecipients user_scope.where(id: user_ids_with_project_setting.concat(user_ids_with_group_setting).uniq) end + + def new_project_watchers + notification_by_sources = related_notification_settings_sources(:watch) + + return if notification_by_sources.blank? + + user_ids = NotificationSetting.from_union(notification_by_sources).select(:user_id) + + user_scope.where(id: user_ids) + end # rubocop: enable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord def group_watchers + return new_group_watchers if Feature.enabled?(:notification_setting_recipient_refactor, project) + user_ids_with_group_global = user_ids_notifiable_on(group, :global) user_ids = user_ids_with_global_level_watch(user_ids_with_group_global) user_ids_with_group_setting = select_group_members_ids(group, [], user_ids_with_group_global, user_ids) user_scope.where(id: user_ids_with_group_setting) end + + def new_group_watchers + return [] unless group + + user_ids = group + .notification_settings + .where(source_or_global_setting_by_level_query(:watch)).select(:user_id) + + user_scope.where(id: user_ids) + end # rubocop: enable CodeReuse/ActiveRecord def add_subscribed_users |