diff options
author | Mario de la Ossa <mariodelaossa@gmail.com> | 2017-12-28 20:25:02 +0300 |
---|---|---|
committer | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-01-17 04:17:55 +0300 |
commit | 23a20c20f826f090446587881df7008a137d2d34 (patch) | |
tree | f1f491f1ab62f40c093ba0f5bd645606c681fd8d /app/models/notification_reason.rb | |
parent | 3228ac06a019c9126b965ff32e354d10011a4f76 (diff) |
Initial work to add notification reason to emails
Adds `#build_notification_recipients` to `NotificationRecipientService`
that returns the `NotificationRecipient` objects in order to be able to
access the new attribute `reason`.
This new attribute is used in the different notifier methods in order to
add the reason as a header: `X-GitLab-NotificationReason`.
Only the reason with the most priority gets sent.
Diffstat (limited to 'app/models/notification_reason.rb')
-rw-r--r-- | app/models/notification_reason.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/notification_reason.rb b/app/models/notification_reason.rb new file mode 100644 index 00000000000..c3965565022 --- /dev/null +++ b/app/models/notification_reason.rb @@ -0,0 +1,19 @@ +# Holds reasons for a notification to have been sent as well as a priority list to select which reason to use +# above the rest +class NotificationReason + OWN_ACTIVITY = 'own_activity'.freeze + ASSIGNED = 'assigned'.freeze + MENTIONED = 'mentioned'.freeze + + # Priority list for selecting which reason to return in the notification + REASON_PRIORITY = [ + OWN_ACTIVITY, + ASSIGNED, + MENTIONED + ].freeze + + # returns the priority of a reason as an integer + def self.priority(reason) + REASON_PRIORITY.index(reason) || REASON_PRIORITY.length + 1 + end +end |