Added IMAP folder support.
This commit is contained in:
parent
ee991e1423
commit
ec1c9a548e
9 changed files with 71 additions and 36 deletions
|
@ -702,10 +702,10 @@ class App.WizardModal extends App.Controller
|
||||||
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
@$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus()
|
||||||
|
|
||||||
showAlert: (screen, message) =>
|
showAlert: (screen, message) =>
|
||||||
@$(".#{screen}").find('.alert').removeClass('hide').text( App.i18n.translateInline( message ) )
|
@$(".#{screen}").find('.alert').first().removeClass('hide').text(App.i18n.translatePlain(message))
|
||||||
|
|
||||||
hideAlert: (screen) =>
|
hideAlert: (screen) =>
|
||||||
@$(".#{screen}").find('.alert').addClass('hide')
|
@$(".#{screen}").find('.alert').first().addClass('hide')
|
||||||
|
|
||||||
disable: (e) =>
|
disable: (e) =>
|
||||||
@formDisable(e)
|
@formDisable(e)
|
||||||
|
|
|
@ -499,6 +499,7 @@ class App.ChannelEmailAccountWizard extends App.WizardModal
|
||||||
{ name: 'email', display: 'Email', tag: 'input', type: 'email', limit: 120, null: false, placeholder: 'support@example.com', autocapitalize: false, autocomplete: 'off' },
|
{ name: 'email', display: 'Email', tag: 'input', type: 'email', limit: 120, null: false, placeholder: 'support@example.com', autocapitalize: false, autocomplete: 'off' },
|
||||||
{ name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true },
|
{ name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true },
|
||||||
{ name: 'group_id', display: 'Destination Group', tag: 'select', null: false, relation: 'Group', nulloption: true },
|
{ name: 'group_id', display: 'Destination Group', tag: 'select', null: false, relation: 'Group', nulloption: true },
|
||||||
|
{ name: 'folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
|
||||||
]
|
]
|
||||||
new App.ControllerForm(
|
new App.ControllerForm(
|
||||||
el: @$('.base-settings'),
|
el: @$('.base-settings'),
|
||||||
|
@ -528,13 +529,25 @@ class App.ChannelEmailAccountWizard extends App.WizardModal
|
||||||
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
|
{ 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::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::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true },
|
||||||
|
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
showHideFolder = (params, attribute, attributes, classname, form, ui) ->
|
||||||
|
return if !params
|
||||||
|
if params.adapter is 'imap'
|
||||||
|
ui.show('options::folder')
|
||||||
|
return
|
||||||
|
ui.hide('options::folder')
|
||||||
|
|
||||||
new App.ControllerForm(
|
new App.ControllerForm(
|
||||||
el: @$('.base-inbound-settings'),
|
el: @$('.base-inbound-settings'),
|
||||||
model:
|
model:
|
||||||
configure_attributes: configureAttributesInbound
|
configure_attributes: configureAttributesInbound
|
||||||
className: ''
|
className: ''
|
||||||
params: @account.inbound
|
params: @account.inbound
|
||||||
|
handlers: [
|
||||||
|
showHideFolder
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
toggleOutboundAdapter: =>
|
toggleOutboundAdapter: =>
|
||||||
|
@ -544,6 +557,7 @@ class App.ChannelEmailAccountWizard extends App.WizardModal
|
||||||
if @account['meta']
|
if @account['meta']
|
||||||
channel_used['options']['user'] = @account['meta']['email']
|
channel_used['options']['user'] = @account['meta']['email']
|
||||||
channel_used['options']['password'] = @account['meta']['password']
|
channel_used['options']['password'] = @account['meta']['password']
|
||||||
|
channel_used['options']['folder'] = @account['meta']['folder']
|
||||||
|
|
||||||
# show used backend
|
# show used backend
|
||||||
@$('.base-outbound-settings').html('')
|
@$('.base-outbound-settings').html('')
|
||||||
|
@ -589,8 +603,8 @@ class App.ChannelEmailAccountWizard extends App.WizardModal
|
||||||
for key, value of data.setting
|
for key, value of data.setting
|
||||||
@account[key] = value
|
@account[key] = value
|
||||||
|
|
||||||
if !@channel && data.content_messages && data.content_messages > 0
|
if data.content_messages && data.content_messages > 0
|
||||||
message = App.i18n.translateContent('We have already found %s emails in your mailbox. Zammad will move it all from your mailbox into Zammad.', data.content_messages)
|
message = App.i18n.translateContent('We have already found %s email(s) in your mailbox. Zammad will move it all from your mailbox into Zammad.', data.content_messages)
|
||||||
@$('.js-inbound-acknowledge .js-message').html(message)
|
@$('.js-inbound-acknowledge .js-message').html(message)
|
||||||
@$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
|
@$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
|
||||||
@$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
|
@$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
|
||||||
|
@ -643,8 +657,8 @@ class App.ChannelEmailAccountWizard extends App.WizardModal
|
||||||
# remember account settings
|
# remember account settings
|
||||||
@account.inbound = params
|
@account.inbound = params
|
||||||
|
|
||||||
if !@channel && data.content_messages && data.content_messages > 0
|
if data.content_messages && data.content_messages > 0
|
||||||
message = App.i18n.translateContent('We have already found %s emails in your mailbox. Zammad will move it all from your mailbox into Zammad.', data.content_messages)
|
message = App.i18n.translateContent('We have already found %s email(s) in your mailbox. Zammad will move it all from your mailbox into Zammad.', data.content_messages)
|
||||||
@$('.js-inbound-acknowledge .js-message').html(message)
|
@$('.js-inbound-acknowledge .js-message').html(message)
|
||||||
@$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound')
|
@$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound')
|
||||||
@$('.js-inbound-acknowledge .js-next').unbind('click.verify')
|
@$('.js-inbound-acknowledge .js-next').unbind('click.verify')
|
||||||
|
|
|
@ -731,7 +731,7 @@ class ChannelEmail extends App.WizardFullScreen
|
||||||
@account[key] = value
|
@account[key] = value
|
||||||
|
|
||||||
if data.content_messages && data.content_messages > 0
|
if data.content_messages && data.content_messages > 0
|
||||||
message = App.i18n.translateContent('We have already found %s emails in your mailbox. Zammad will move it all from your mailbox into Zammad.', data.content_messages)
|
message = App.i18n.translateContent('We have already found %s email(s) in your mailbox. Zammad will move it all from your mailbox into Zammad.', data.content_messages)
|
||||||
@$('.js-inbound-acknowledge .js-message').html(message)
|
@$('.js-inbound-acknowledge .js-message').html(message)
|
||||||
@$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
|
@$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro')
|
||||||
@$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
|
@$('.js-inbound-acknowledge .js-next').attr('data-slide', '')
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><%- @T('User') %>
|
<td><%- @T('User') %>
|
||||||
<td><%= channel.options.inbound.options.user %>
|
<td><%= channel.options.inbound.options.user %>
|
||||||
|
<% if channel.options.inbound.options.folder: %>
|
||||||
|
(<%- @T('Folder') %>: <%= channel.options.inbound.options.folder %>)
|
||||||
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%- @T('Host') %>
|
<td><%- @T('Host') %>
|
||||||
<td><%= channel.options.inbound.options.host %>
|
<td><%= channel.options.inbound.options.host %>
|
||||||
|
|
|
@ -149,6 +149,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
|
||||||
result = EmailHelper::Probe.full(
|
result = EmailHelper::Probe.full(
|
||||||
email: params[:email],
|
email: params[:email],
|
||||||
password: params[:password],
|
password: params[:password],
|
||||||
|
folder: params[:folder],
|
||||||
)
|
)
|
||||||
|
|
||||||
# verify if user+host already exists
|
# verify if user+host already exists
|
||||||
|
|
|
@ -90,7 +90,7 @@ returns
|
||||||
# check mode only
|
# check mode only
|
||||||
if check_type == 'check'
|
if check_type == 'check'
|
||||||
Rails.logger.info 'check only mode, fetch no emails'
|
Rails.logger.info 'check only mode, fetch no emails'
|
||||||
content_max_check = 5
|
content_max_check = 2
|
||||||
content_messages = 0
|
content_messages = 0
|
||||||
|
|
||||||
# check messages
|
# check messages
|
||||||
|
|
|
@ -8,6 +8,7 @@ get result of probe
|
||||||
result = EmailHelper::Probe.full(
|
result = EmailHelper::Probe.full(
|
||||||
email: 'znuny@example.com',
|
email: 'znuny@example.com',
|
||||||
password: 'somepassword',
|
password: 'somepassword',
|
||||||
|
folder: 'some_folder', # optional im imap
|
||||||
)
|
)
|
||||||
|
|
||||||
returns on success
|
returns on success
|
||||||
|
@ -23,6 +24,7 @@ returns on success
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: 'some@example.com',
|
user: 'some@example.com',
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
folder: 'some_folder', # optional im imap
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
outbound: {
|
outbound: {
|
||||||
|
@ -71,6 +73,11 @@ returns on fail
|
||||||
|
|
||||||
next if domain_to_check !~ /#{settings[:domain]}/i
|
next if domain_to_check !~ /#{settings[:domain]}/i
|
||||||
|
|
||||||
|
# add folder to config if needed
|
||||||
|
if !params[:folder].empty? && settings[:inbound] && settings[:inbound][:options]
|
||||||
|
settings[:inbound][:options][:folder] = params[:folder]
|
||||||
|
end
|
||||||
|
|
||||||
# probe inbound
|
# probe inbound
|
||||||
Rails.logger.debug "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}"
|
Rails.logger.debug "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}"
|
||||||
result_inbound = EmailHelper::Probe.inbound(settings[:inbound])
|
result_inbound = EmailHelper::Probe.inbound(settings[:inbound])
|
||||||
|
@ -103,6 +110,12 @@ returns on fail
|
||||||
}
|
}
|
||||||
success = false
|
success = false
|
||||||
inbound_map.each {|config|
|
inbound_map.each {|config|
|
||||||
|
|
||||||
|
# add folder to config if needed
|
||||||
|
if !params[:folder].empty? && config[:options]
|
||||||
|
config[:options][:folder] = params[:folder]
|
||||||
|
end
|
||||||
|
|
||||||
Rails.logger.debug "INBOUND PROBE GUESS: #{config.inspect}"
|
Rails.logger.debug "INBOUND PROBE GUESS: #{config.inspect}"
|
||||||
result_inbound = EmailHelper::Probe.inbound(config)
|
result_inbound = EmailHelper::Probe.inbound(config)
|
||||||
Rails.logger.debug "INBOUND RESULT GUESS: #{result_inbound.inspect}"
|
Rails.logger.debug "INBOUND RESULT GUESS: #{result_inbound.inspect}"
|
||||||
|
@ -165,6 +178,7 @@ get result of inbound probe
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: 'some@example.com',
|
user: 'some@example.com',
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
folder: 'some_folder', # optional
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -184,6 +198,7 @@ returns on fail
|
||||||
ssl: true,
|
ssl: true,
|
||||||
user: 'some@example.com',
|
user: 'some@example.com',
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
folder: 'some_folder', # optional im imap
|
||||||
},
|
},
|
||||||
message: 'error message from used lib',
|
message: 'error message from used lib',
|
||||||
message_human: 'translated error message, readable for humans',
|
message_human: 'translated error message, readable for humans',
|
||||||
|
@ -365,6 +380,8 @@ returns on fail
|
||||||
'No route to host' => { host: true },
|
'No route to host' => { host: true },
|
||||||
'execution expired' => { host: true },
|
'execution expired' => { host: true },
|
||||||
'Connection refused' => { host: true },
|
'Connection refused' => { host: true },
|
||||||
|
'Mailbox doesn\'t exist' => { folder: true },
|
||||||
|
'Folder doesn\'t exist' => { folder: true },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue