diff options
author | Sean McGivern <sean@gitlab.com> | 2017-03-30 12:29:52 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-04-03 13:59:48 +0100 |
commit | a1805cbcd55a28658049b42c12a87a50ab9ab977 (patch) | |
tree | aeab49a23df0bb52a8900e01a5c7348570f8bcef /app/models/notification_setting.rb | |
parent | 2faf955c241ce7e99111f8fd0cae2e7ab6167e5a (diff) | |
download | gitlab-ce-a1805cbcd55a28658049b42c12a87a50ab9ab977.tar.gz |
Quiet pipeline emailsquiet-pipelines
1. Never send a pipeline email to anyone other than the user who created
the pipeline.
2. Only send pipeline success emails to people with the custom
notification setting for enabled. Watchers and participants will
never receive this.
3. When custom settings are unset (for new settings and legacy ones),
act as if failed_pipeline is set.
Diffstat (limited to 'app/models/notification_setting.rb')
-rw-r--r-- | app/models/notification_setting.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb index 52577bd52ea..e4726e62e93 100644 --- a/app/models/notification_setting.rb +++ b/app/models/notification_setting.rb @@ -60,16 +60,25 @@ class NotificationSetting < ActiveRecord::Base def set_events return if custom? - EMAIL_EVENTS.each do |event| - events[event] = false - end + self.events = {} end # Validates store accessors values as boolean # It is a text field so it does not cast correct boolean values in JSON def events_to_boolean EMAIL_EVENTS.each do |event| - events[event] = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(events[event]) + bool = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(public_send(event)) + + events[event] = bool end end + + # Allow people to receive failed pipeline notifications if they already have + # custom notifications enabled, as these are more like mentions than the other + # custom settings. + def failed_pipeline + bool = super + + bool.nil? || bool + end end |