From 545289c29b42f064768046a205d7fd5a62e516fc Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Tue, 19 Apr 2022 09:45:53 +0200 Subject: [PATCH] Fixes #4060 - Error on second migration of an microsoft365 channel undefined method `options' for nil:NilClass. --- .../controllers/_channel/microsoft365.coffee | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_channel/microsoft365.coffee b/app/assets/javascripts/app/controllers/_channel/microsoft365.coffee index 596737922..a02990222 100644 --- a/app/assets/javascripts/app/controllers/_channel/microsoft365.coffee +++ b/app/assets/javascripts/app/controllers/_channel/microsoft365.coffee @@ -95,10 +95,14 @@ class ChannelAccountOverview extends App.ControllerSubContent channels.push channel - # auto redirect to gmail account linking if we have no account - if @channel_id && channels.length < 1 - @new() - return + # on a channel migration we need to auto redirect + # the user to the "Add Account" functionality after + # the filled up the external credentials + if @channel_id + item = App.Channel.find(@channel_id) + if item && item.area != 'Microsoft365::Account' + @new() + return # get all unlinked email addresses not_used_email_addresses = [] @@ -111,9 +115,14 @@ class ChannelAccountOverview extends App.ControllerSubContent not_used_email_addresses: not_used_email_addresses ) + # on a channel creation we will auto open the edit + # dialog after the redirect back to zammad to optional + # change the inbound configuration, but not for + # migrated channel because we guess that the inbound configuration + # is already correct for them. if @channel_id item = App.Channel.find(@channel_id) - if item && item.options && item.options.backup_imap_classic is undefined + if item && item.area == 'Microsoft365::Account' && item.options && item.options.backup_imap_classic is undefined @editInbound(undefined, @channel_id, true) @channel_id = undefined