From 365cdd8fe0d107257ba5af47b80b66f08217b6bc Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 22 Dec 2016 00:36:10 +0800 Subject: [PATCH 1/2] Make successful pipeline emails off for watchers Closes #24845 --- app/services/notification_service.rb | 6 +++++- .../remove-successful-pipeline-emails-for-now.yml | 4 ++++ doc/workflow/notifications.md | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/remove-successful-pipeline-emails-for-now.yml diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 9a7af5730d2..75277d3ac12 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -591,7 +591,11 @@ class NotificationService custom_action = build_custom_key(action, target) recipients = target.participants(current_user) - recipients = add_project_watchers(recipients, project) + + # TODO: CLEAN ME UP! + unless custom_action == :success_pipeline + recipients = add_project_watchers(recipients, project) + end recipients = add_custom_notifications(recipients, project, custom_action) recipients = reject_mention_users(recipients, project) diff --git a/changelogs/unreleased/remove-successful-pipeline-emails-for-now.yml b/changelogs/unreleased/remove-successful-pipeline-emails-for-now.yml new file mode 100644 index 00000000000..47d484e5c84 --- /dev/null +++ b/changelogs/unreleased/remove-successful-pipeline-emails-for-now.yml @@ -0,0 +1,4 @@ +--- +title: Make successful pipeline emails off for watchers +merge_request: 8176 +author: diff --git a/doc/workflow/notifications.md b/doc/workflow/notifications.md index c936e8833c6..4c52974e103 100644 --- a/doc/workflow/notifications.md +++ b/doc/workflow/notifications.md @@ -73,7 +73,7 @@ In all of the below cases, the notification will be sent to: ...with notification level "Participating" or higher -- Watchers: users with notification level "Watch" +- Watchers: users with notification level "Watch" (however successful pipeline would be off for watchers) - Subscribers: anyone who manually subscribed to the issue/merge request - Custom: Users with notification level "custom" who turned on notifications for any of the events present in the table below From ce7c632f5098a53b0977ec8531a9f53e61ddbe8d Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 5 Jan 2017 19:31:11 +0800 Subject: [PATCH 2/2] Introduce EXCLUDED_WATCHER_EVENTS to exclude events for watchers. Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8176#note_20920905 --- app/models/notification_setting.rb | 4 ++++ app/services/notification_service.rb | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb index 43fc218de2b..58f6214bea7 100644 --- a/app/models/notification_setting.rb +++ b/app/models/notification_setting.rb @@ -37,6 +37,10 @@ class NotificationSetting < ActiveRecord::Base :success_pipeline ] + EXCLUDED_WATCHER_EVENTS = [ + :success_pipeline + ] + store :events, accessors: EMAIL_EVENTS, coder: JSON before_create :set_events diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 75277d3ac12..c3b61e68eab 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -592,8 +592,7 @@ class NotificationService recipients = target.participants(current_user) - # TODO: CLEAN ME UP! - unless custom_action == :success_pipeline + unless NotificationSetting::EXCLUDED_WATCHER_EVENTS.include?(custom_action) recipients = add_project_watchers(recipients, project) end