diff options
author | Rémy Coutable <remy@rymai.me> | 2016-01-15 15:28:16 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-01-15 15:28:16 +0100 |
commit | 51266f41b3150b3a198bf8316d093a86d4d38cd1 (patch) | |
tree | 3c4ab73c382c48fb9ab114f3a1f5d335159f8339 /app | |
parent | f093d8ccb4101e160bf2a89ec1f9ebe9d73f84fc (diff) | |
download | gitlab-ce-51266f41b3150b3a198bf8316d093a86d4d38cd1.tar.gz |
Consider re-assign as a mention from a notification point of view
This will ensure new assignee gets an email even if his notif level is
"on mention".
Diffstat (limited to 'app')
-rw-r--r-- | app/services/notification_service.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index e4edc55bf69..60b86914a38 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -379,7 +379,7 @@ class NotificationService previous_assignee_id = previous_record(target, "assignee_id") previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id - recipients = build_recipients(target, project, current_user, [previous_assignee]) + recipients = build_recipients(target, project, current_user, action: :reassign, extra_recipients: [previous_assignee]) recipients.each do |recipient| mailer.send( @@ -400,22 +400,28 @@ class NotificationService end end - def build_recipients(target, project, current_user, extra_recipients = nil) + def build_recipients(target, project, current_user, action: nil, extra_recipients: nil) recipients = target.participants(current_user) recipients = recipients.concat(extra_recipients).compact.uniq if extra_recipients recipients = add_project_watchers(recipients, project) recipients = reject_mention_users(recipients, project) - recipients = reject_muted_users(recipients, project) + # Re-assign is considered as a mention of the new assignee so we add the + # new assignee to the list of recipients after we rejected users with + # the "on mention" notification level + if action == :reassign + recipients << target.assignee + end + + recipients = reject_muted_users(recipients, project) recipients = add_subscribed_users(recipients, target) recipients = reject_unsubscribed_users(recipients, target) recipients.delete(current_user) - recipients = recipients.uniq - recipients + recipients.uniq end def mailer |