From 90468ffe48630eb7bc7d06c7b3e6caa70555316d Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 25 May 2023 13:28:42 -0400 Subject: [PATCH] handle missing callerId property for anonymous calls --- lib/http-routes/api/create-call.js | 3 ++- lib/tasks/dial.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/http-routes/api/create-call.js b/lib/http-routes/api/create-call.js index 6b37500f..d5ad0da8 100644 --- a/lib/http-routes/api/create-call.js +++ b/lib/http-routes/api/create-call.js @@ -92,7 +92,8 @@ router.post('/', async(req, res) => { * */ if (target.type === 'phone' && !target.trunk) { const {lookupCarrierByPhoneNumber} = dbUtils(this.logger, srf); - const callingNumber = restDial.from.startsWith('+') ? restDial.from.substring(1) : restDial.from; + const str = restDial.from || ''; + const callingNumber = str.startsWith('+') ? str.substring(1) : str; const voip_carrier_sid = await lookupCarrierByPhoneNumber(req.body.account_sid, callingNumber); logger.info( `createCall: selected ${voip_carrier_sid} for requested phone number: ${callingNumber || 'unspecified'})`); diff --git a/lib/tasks/dial.js b/lib/tasks/dial.js index 69a3eeb6..49be55ae 100644 --- a/lib/tasks/dial.js +++ b/lib/tasks/dial.js @@ -470,7 +470,7 @@ class TaskDial extends Task { * check if number matches any existing numbers * */ if (t.type === 'phone' && !t.trunk) { - const str = this.callerId || req.callingNumber; + 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(