Commit 8c308e3d authored by Douwe Maan's avatar Douwe Maan

Don't fail when there was no previous assignee

parent 1ca55082
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment