Permalink
Browse files

Implemented issue #2223 - Callback issue when Zammad if internal and …

…external FQDN differ.
  • Loading branch information...
znuny-robo committed Oct 10, 2018
1 parent 5ff371f commit 7dd6675552e10409db98c9eccaaaf540d0a929b8
@@ -118,7 +118,10 @@ def xml_error(error)
def base_url
http_type = Setting.get('http_type')
fqdn = Setting.get('fqdn')
fqdn = Setting.get('sipgate_alternative_fqdn')
if fqdn.blank?
fqdn = Setting.get('fqdn')
end
"#{http_type}://#{fqdn}/api/v1/sipgate"
end
@@ -0,0 +1,30 @@
class SettingAddSipgateAlternativeFqdn < ActiveRecord::Migration[5.1]
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Setting.create_if_not_exists(
title: 'sipgate.io alternative fqdn',
name: 'sipgate_alternative_fqdn',
area: 'Integration::Sipgate::Expert',
description: 'Alternative FQDN for callbacks if you operate Zammad in internal network.',
options: {
form: [
{
display: '',
null: false,
name: 'sipgate_alternative_fqdn',
tag: 'input',
},
],
},
state: '',
preferences: {
permission: ['admin.integration'],
},
frontend: false
)
end
end
View
@@ -3913,6 +3913,27 @@
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'sipgate.io alternative fqdn',
name: 'sipgate_alternative_fqdn',
area: 'Integration::Sipgate::Expert',
description: 'Alternative FQDN for callbacks if you operate Zammad in internal network.',
options: {
form: [
{
display: '',
null: false,
name: 'sipgate_alternative_fqdn',
tag: 'input',
},
],
},
state: '',
preferences: {
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'cti integration',
name: 'cti_integration',
@@ -441,5 +441,24 @@
expect(json_response['list'][4]['state']).to eq('hangup')
expect(json_response['list'][5]['call_id']).to eq('1234567890-1')
end
it 'alternative fqdn' do
Setting.set('sipgate_alternative_fqdn', 'external.host.example.com')
# inbound - I
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
post '/api/v1/sipgate/in', params: params
expect(@response).to have_http_status(200)
on_hangup = nil
on_answer = nil
content = @response.body
response = REXML::Document.new(content)
response.elements.each('Response') do |element|
on_hangup = element.attributes['onHangup']
on_answer = element.attributes['onAnswer']
end
expect(on_hangup).to eq('http://external.host.example.com/api/v1/sipgate/in')
expect(on_answer).to eq('http://external.host.example.com/api/v1/sipgate/in')
end
end
end

0 comments on commit 7dd6675

Please sign in to comment.