feat: lcr

This commit is contained in:
Quan HL
2023-04-24 21:40:19 +07:00
parent 6dc019e836
commit 2e3d783dee
3 changed files with 41 additions and 6 deletions

View File

@@ -91,8 +91,13 @@ router.post('/', async(req, res) => {
* check if from-number matches any existing numbers on Jambonz
* */
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 {lookupCarrierByPhoneNumber, lookupCarrierByLcr} = dbUtils(this.logger, srf);
// firstly LCR
let voip_carrier_sid = await lookupCarrierByLcr(req.body.account_sid, to);
if (!voip_carrier_sid) {
// later by phone
voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, restDial.from);
}
logger.info(
`createCall: selected ${voip_carrier_sid} for requested phone number: ${restDial.from || 'unspecified'})`);
if (voip_carrier_sid) {