diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-11-17 16:51:35 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-11-17 16:51:35 +0100 |
commit | 8c308e3df6b2c9b259f66172d13cc81009c1ae89 (patch) | |
tree | c3d1f68be916148ba3727a1d1f3d2a119d8e2b28 /app/services | |
parent | 1ca550823b60b1435e9b2519f2c4d8fa84f4d25b (diff) | |
download | gitlab-ce-8c308e3df6b2c9b259f66172d13cc81009c1ae89.tar.gz |
Don't fail when there was no previous assignee
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/notification_service.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 16c84f4a055..27928c0945b 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -113,7 +113,7 @@ class NotificationService end # Add all users participating in the thread (author, assignee, comment authors) - participants = + participants = if target.respond_to?(:participants) target.participants(note.author) else @@ -325,7 +325,7 @@ class NotificationService def reject_unsubscribed_users(recipients, target) return recipients unless target.respond_to? :subscriptions - + recipients.reject do |user| subscription = target.subscriptions.find_by_user_id(user.id) subscription && !subscription.subscribed @@ -343,7 +343,7 @@ class NotificationService recipients end end - + def new_resource_email(target, project, method) recipients = build_recipients(target, project, target.author) @@ -361,12 +361,13 @@ class NotificationService end def reassign_resource_email(target, project, current_user, method) - assignee_id_was = previous_record(target, "assignee_id") - previous_assignee = User.find(assignee_id_was) + 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.each do |recipient| - mailer.send(method, recipient.id, target.id, assignee_id_was, current_user.id) + mailer.send(method, recipient.id, target.id, previous_assignee_id, current_user.id) end end @@ -378,9 +379,10 @@ class NotificationService end end - def build_recipients(target, project, current_user, previous_records = nil ) + def build_recipients(target, project, current_user, extra_recipients = nil ) recipients = target.participants(current_user) - recipients.concat(previous_records).compact.uniq if previous_records + + recipients = recipients.concat(extra_recipients).compact.uniq if extra_recipients recipients = add_project_watchers(recipients, project) recipients = reject_mention_users(recipients, project) |