From cc9977460e0885479aa7d737bc47301b6e4459ea Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 3 Mar 2022 10:04:12 +0100 Subject: [PATCH] Fixes #3964 - Selecting custom ports for mail channel ends in 'host not reachable'. --- .../app/controllers/_channel/email.coffee | 19 ++++++++++++--- .../getting_started/channel_email.coffee | 19 ++++++++++++--- app/models/channel/driver/imap.rb | 14 +++++------ app/models/channel/driver/pop3.rb | 22 ++++++++--------- ...216131241_issue3964_inbound_fix_options.rb | 21 ++++++++++++++++ i18n/zammad.pot | 15 ++++++++++++ lib/external_credential/google.rb | 2 +- lib/external_credential/microsoft365.rb | 2 +- .../issue_3964_inbound_fix_options_spec.rb | 24 +++++++++++++++++++ spec/factories/channel.rb | 4 ++-- spec/lib/auto_wizard_spec.rb | 4 ++-- spec/lib/external_credential/google_spec.rb | 2 +- .../external_credential/microsoft365_spec.rb | 2 +- spec/system/channels/email_spec.rb | 4 ++-- 14 files changed, 118 insertions(+), 36 deletions(-) create mode 100644 db/migrate/20220216131241_issue3964_inbound_fix_options.rb create mode 100644 spec/db/migrate/issue_3964_inbound_fix_options_spec.rb diff --git a/app/assets/javascripts/app/controllers/_channel/email.coffee b/app/assets/javascripts/app/controllers/_channel/email.coffee index 7c0e1af85..b61652e6c 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.coffee @@ -307,6 +307,7 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal events: 'submit .js-intro': 'probeBasedOnIntro' 'submit .js-inbound': 'probeInbound' + 'change .js-inbound [name=adapter]': 'toggleInboundAdapter' 'change .js-outbound [name=adapter]': 'toggleOutboundAdapter' 'submit .js-outbound': 'probleOutbound' 'click .js-goToSlide': 'goToSlide' @@ -404,7 +405,7 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal { name: 'options::host', display: __('Host'), tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false }, { name: 'options::user', display: __('User'), tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autocomplete: 'off' }, { name: 'options::password', display: __('Password'), tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true }, - { name: 'options::ssl', display: __('SSL/STARTTLS'), tag: 'boolean', null: true, options: { true: 'yes', false: 'no' }, default: true, translate: true, item_class: 'formGroup--halfSize' }, + { name: 'options::ssl', display: __('SSL/STARTTLS'), tag: 'select', null: true, options: { 'off': __('No SSL'), 'ssl': __('SSL'), 'starttls': __('STARTTLS') }, default: 'ssl', translate: true, item_class: 'formGroup--halfSize' }, { name: 'options::port', display: __('Port'), tag: 'input', type: 'text', limit: 6, null: true, autocapitalize: false, default: '993', item_class: 'formGroup--halfSize' }, { name: 'options::folder', display: __('Folder'), tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, item_class: 'formGroup--halfSize' }, { name: 'options::keep_on_server', display: __('Keep messages on server'), tag: 'boolean', null: true, options: { true: 'yes', false: 'no' }, translate: true, default: false, item_class: 'formGroup--halfSize' }, @@ -438,14 +439,26 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal showHideFolder, ] ) + @toggleInboundAdapter() form.el.find("select[name='options::ssl']").off('change').on('change', (e) -> - if $(e.target).val() is 'true' + if $(e.target).val() is 'ssl' form.el.find("[name='options::port']").val('993') - else + else if $(e.target).val() is 'off' form.el.find("[name='options::port']").val('143') ) + toggleInboundAdapter: => + form = @$('.base-inbound-settings') + adapter = form.find("select[name='adapter']") + starttls = form.find("select[name='options::ssl'] option[value='starttls']") + + if adapter.val() isnt 'imap' + starttls.remove() + else if starttls.length < 1 + starttls = $('