diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-19 11:37:14 +0100 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-01-19 12:12:35 -0500 |
commit | 52124655e1d24b0594883fb66152442a3622d63a (patch) | |
tree | d8f0ac09cd512b2cb99ef8ecc72da3012205a23e /app | |
parent | 21a2942dafc82db15eb06e9ac42755bf9f3aad74 (diff) | |
download | gitlab-ce-52124655e1d24b0594883fb66152442a3622d63a.tar.gz |
Merge branch 'fix-consider-re-assign-as-a-mention'
Diffstat (limited to 'app')
-rw-r--r-- | app/services/notification_service.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index e4edc55bf69..ca8a41d93b8 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -376,10 +376,10 @@ class NotificationService end def reassign_resource_email(target, project, current_user, method) - previous_assignee_id = previous_record(target, "assignee_id") + 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, previous_assignee: previous_assignee) recipients.each do |recipient| mailer.send( @@ -400,22 +400,27 @@ class NotificationService end end - def build_recipients(target, project, current_user, extra_recipients = nil) + def build_recipients(target, project, current_user, action: nil, previous_assignee: 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 << previous_assignee if previous_assignee + 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 |