mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-13 01:39:26 +00:00
fix inband dtmf does not work in dial verb (#1018)
This commit is contained in:
@@ -521,7 +521,7 @@ class TaskDial extends Task {
|
|||||||
const {req, callInfo, direction, srf} = cs;
|
const {req, callInfo, direction, srf} = cs;
|
||||||
const {getSBC} = srf.locals;
|
const {getSBC} = srf.locals;
|
||||||
const {lookupTeamsByAccount, lookupAccountBySid} = srf.locals.dbHelpers;
|
const {lookupTeamsByAccount, lookupAccountBySid} = srf.locals.dbHelpers;
|
||||||
const {lookupCarrier, lookupCarrierByPhoneNumber} = dbUtils(this.logger, cs.srf);
|
const {lookupCarrier, lookupCarrierByPhoneNumber, lookupVoipCarrierBySid} = dbUtils(this.logger, cs.srf);
|
||||||
let sbcAddress = this.proxy || getSBC();
|
let sbcAddress = this.proxy || getSBC();
|
||||||
const teamsInfo = {};
|
const teamsInfo = {};
|
||||||
let fqdn;
|
let fqdn;
|
||||||
@@ -540,6 +540,8 @@ class TaskDial extends Task {
|
|||||||
...this.headers
|
...this.headers
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// default to inband dtmf if not specified
|
||||||
|
this.inbandDtmfEnabled = cs.inbandDtmfEnabled;
|
||||||
// get calling user from From header
|
// get calling user from From header
|
||||||
const parsedFrom = req.getParsedHeader('from');
|
const parsedFrom = req.getParsedHeader('from');
|
||||||
const fromUri = parseUri(parsedFrom.uri);
|
const fromUri = parseUri(parsedFrom.uri);
|
||||||
@@ -617,10 +619,17 @@ class TaskDial extends Task {
|
|||||||
const str = this.callerId || req.callingNumber || '';
|
const str = this.callerId || req.callingNumber || '';
|
||||||
const callingNumber = str.startsWith('+') ? str.substring(1) : str;
|
const callingNumber = str.startsWith('+') ? str.substring(1) : str;
|
||||||
const voip_carrier_sid = await lookupCarrierByPhoneNumber(cs.accountSid, callingNumber);
|
const voip_carrier_sid = await lookupCarrierByPhoneNumber(cs.accountSid, callingNumber);
|
||||||
|
const req_voip_carrier_sid = req.has('X-Voip-Carrier-Sid') ? req.get('X-Voip-Carrier-Sid') : null;
|
||||||
if (voip_carrier_sid) {
|
if (voip_carrier_sid) {
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
`Dial:_attemptCalls: selected voip_carrier_sid ${voip_carrier_sid} for callingNumber: ${callingNumber}`);
|
`Dial:_attemptCalls: selected voip_carrier_sid ${voip_carrier_sid} for callingNumber: ${callingNumber}`);
|
||||||
opts.headers['X-Requested-Carrier-Sid'] = voip_carrier_sid;
|
opts.headers['X-Requested-Carrier-Sid'] = voip_carrier_sid;
|
||||||
|
|
||||||
|
// Checking if outbound carrier is different from inbound carrier and has dtmf type tones
|
||||||
|
if (voip_carrier_sid !== req_voip_carrier_sid) {
|
||||||
|
const [voipCarrier] = await lookupVoipCarrierBySid(voip_carrier_sid);
|
||||||
|
this.inbandDtmfEnabled = voipCarrier?.dtmf_type === 'tones';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -349,6 +349,15 @@ class SingleDialer extends Emitter {
|
|||||||
if (Object.keys(opts).length > 0) {
|
if (Object.keys(opts).length > 0) {
|
||||||
this.ep.set(opts);
|
this.ep.set(opts);
|
||||||
}
|
}
|
||||||
|
if (this.dialTask?.inbandDtmfEnabled && !this.ep.inbandDtmfEnabled) {
|
||||||
|
// https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Modules/mod-dptools/6587132/#0-about
|
||||||
|
try {
|
||||||
|
this.ep.execute('start_dtmf');
|
||||||
|
this.ep.inbandDtmfEnabled = true;
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.info(err, 'place-outdial:_configMsEndpoint - error enable inband DTMF');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user