Implemented issue #2223 - Callback issue when Zammad if internal and external FQDN differ.
This commit is contained in:
parent
5ff371f51b
commit
7dd6675552
4 changed files with 74 additions and 1 deletions
|
@ -118,7 +118,10 @@ class Integration::SipgateController < ApplicationController
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
http_type = Setting.get('http_type')
|
http_type = Setting.get('http_type')
|
||||||
|
fqdn = Setting.get('sipgate_alternative_fqdn')
|
||||||
|
if fqdn.blank?
|
||||||
fqdn = Setting.get('fqdn')
|
fqdn = Setting.get('fqdn')
|
||||||
|
end
|
||||||
"#{http_type}://#{fqdn}/api/v1/sipgate"
|
"#{http_type}://#{fqdn}/api/v1/sipgate"
|
||||||
end
|
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
|
|
@ -3913,6 +3913,27 @@ Setting.create_if_not_exists(
|
||||||
},
|
},
|
||||||
frontend: false,
|
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(
|
Setting.create_if_not_exists(
|
||||||
title: 'cti integration',
|
title: 'cti integration',
|
||||||
name: 'cti_integration',
|
name: 'cti_integration',
|
||||||
|
|
|
@ -441,5 +441,24 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
expect(json_response['list'][4]['state']).to eq('hangup')
|
expect(json_response['list'][4]['state']).to eq('hangup')
|
||||||
expect(json_response['list'][5]['call_id']).to eq('1234567890-1')
|
expect(json_response['list'][5]['call_id']).to eq('1234567890-1')
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue