fix for #359 - selection of outbound carrier based on calling number

This commit is contained in:
Dave Horton
2023-05-25 13:11:57 -04:00
committed by Dave Horton
parent 7393e3bcb7
commit 484be8442c
2 changed files with 7 additions and 4 deletions

View File

@@ -92,9 +92,10 @@ router.post('/', async(req, res) => {
* */
if (target.type === 'phone' && !target.trunk) {
const {lookupCarrierByPhoneNumber} = dbUtils(this.logger, srf);
const voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, restDial.from);
const callingNumber = restDial.from.startsWith('+') ? restDial.from.substring(1) : restDial.from;
const voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, callingNumber);
logger.info(
`createCall: selected ${voip_carrier_sid} for requested phone number: ${restDial.from || 'unspecified'})`);
`createCall: selected ${voip_carrier_sid} for requested phone number: ${callingNumber || 'unspecified'})`);
if (voip_carrier_sid) {
opts.headers['X-Requested-Carrier-Sid'] = voip_carrier_sid;
}

View File

@@ -470,9 +470,11 @@ class TaskDial extends Task {
* check if number matches any existing numbers
* */
if (t.type === 'phone' && !t.trunk) {
const voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, t.number);
const str = this.callerId || req.callingNumber;
const callingNumber = str.startsWith('+') ? str.substring(1) : str;
const voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, callingNumber);
this.logger.info(
`Dial:_attemptCalls: selected ${voip_carrier_sid} for requested phone number: ${t.number})`);
`Dial:_attemptCalls: selected ${voip_carrier_sid} for requested phone number: ${callingNumber})`);
if (voip_carrier_sid) {
opts.headers['X-Requested-Carrier-Sid'] = voip_carrier_sid;
}