Class: NotificationSetting
Constant Summary
collapse
- EMAIL_EVENTS =
NOTE: Applicable unfound_translations.rb also needs to be updated when below events are changed.
[
:new_release,
:new_note,
:new_issue,
:reopen_issue,
:close_issue,
:reassign_issue,
:issue_due,
:new_merge_request,
:push_to_merge_request,
:reopen_merge_request,
:close_merge_request,
:reassign_merge_request,
:change_reviewer_merge_request,
:merge_merge_request,
:failed_pipeline,
:fixed_pipeline,
:success_pipeline,
:moved_project,
:merge_when_pipeline_succeeds
].freeze
- EXCLUDED_WATCHER_EVENTS =
[
:push_to_merge_request,
:issue_due,
:success_pipeline
].freeze
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Class Method Details
.allowed_fields(source = nil) ⇒ Object
62
63
64
|
# File 'app/models/notification_setting.rb', line 62
def self.allowed_fields(source = nil)
NotificationSetting.email_events(source).dup + %i[level notification_email]
end
|
.email_events(source = nil) ⇒ Object
58
59
60
|
# File 'app/models/notification_setting.rb', line 58
def self.email_events(source = nil)
EMAIL_EVENTS
end
|
.find_or_create_for(source) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'app/models/notification_setting.rb', line 76
def self.find_or_create_for(source)
setting = find_or_initialize_by(source: source)
unless setting.persisted?
setting.save
end
setting
end
|
Instance Method Details
#email_events ⇒ Object
66
67
68
|
# File 'app/models/notification_setting.rb', line 66
def email_events
self.class.email_events(source)
end
|
#event_enabled?(event) ⇒ Boolean
103
104
105
106
107
108
109
|
# File 'app/models/notification_setting.rb', line 103
def event_enabled?(event)
return failed_pipeline if event.to_sym == :failed_pipeline
return fixed_pipeline if event.to_sym == :fixed_pipeline
has_attribute?(event) && !!read_attribute(event)
end
|
#failed_pipeline ⇒ Object
Also known as:
failed_pipeline?
Allow people to receive both failed pipeline/fixed pipeline notifications if they already have custom notifications enabled, as these are more like mentions than the other custom settings.
89
90
91
92
93
|
# File 'app/models/notification_setting.rb', line 89
def failed_pipeline
bool = super
bool.nil? || bool
end
|
#fixed_pipeline ⇒ Object
Also known as:
fixed_pipeline?
96
97
98
99
100
|
# File 'app/models/notification_setting.rb', line 96
def fixed_pipeline
bool = super
bool.nil? || bool
end
|
#notification_email_verified ⇒ Object
111
112
113
114
115
116
|
# File 'app/models/notification_setting.rb', line 111
def notification_email_verified
return if user.temp_oauth_email?
return if notification_email.empty?
errors.add(:notification_email, _("must be an email you have verified")) unless user.verified_emails.include?(notification_email)
end
|