Imporoved zendesk reload feature at import time. Improved url validation.

This commit is contained in:
Martin Edenhofer 2017-08-17 13:48:55 +02:00
parent 4a24bb8507
commit f7bd2dfceb
2 changed files with 4 additions and 3 deletions

View file

@ -117,7 +117,7 @@ class Index extends App.ControllerContent
e.preventDefault()
@urlStatus.attr('data-state', '')
url = @zendeskUrl.val() + '/agent/admin/api'
@zendeskUrlApiToken.attr('href', url.replace(/[^:]\/\//, '/'))
@zendeskUrlApiToken.attr('href', url.replace(/([^:])\/\/+/g, '$1/'))
@zendeskUrlApiToken.val('HERE')
@$('[data-slide=zendesk-url]').toggleClass('hide')
@$('[data-slide=zendesk-credentials]').toggleClass('hide')

View file

@ -7,7 +7,7 @@ class ImportZendeskController < ApplicationController
return if setup_done_response
# validate
if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
if params[:url].blank? || params[:url] !~ %r{^(http|https)://.+?$}
render json: {
result: 'invalid',
message: 'Invalid URL!',
@ -50,7 +50,7 @@ class ImportZendeskController < ApplicationController
end
endpoint = "#{params[:url]}/api/v2"
endpoint.gsub(%r{[^:]//}, '/')
endpoint.gsub!(%r{([^:])//+}, '\\1/')
Setting.set('import_zendesk_endpoint', endpoint)
render json: {
@ -94,6 +94,7 @@ class ImportZendeskController < ApplicationController
def import_start
return if setup_done_response
Setting.set('import_mode', true)
Setting.set('import_backend', 'zendesk')
# start migration
Import::Zendesk.delay.start_bg