From 2f137f2bfc0c93ec3cf6ff0566080589d0b54949 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Sun, 22 Jan 2023 18:03:12 -0500 Subject: [PATCH] bugfix: handle calls with no user in To header --- lib/db-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/db-utils.js b/lib/db-utils.js index b76610b..43ee6da 100644 --- a/lib/db-utils.js +++ b/lib/db-utils.js @@ -100,7 +100,7 @@ module.exports = (srf, logger) => { }; const getApplicationForDidAndCarrier = async(req, voip_carrier_sid) => { - const did = normalizeDID(req.calledNumber); + const did = normalizeDID(req.calledNumber) || 'anonymous'; try { /* straight DID match */ @@ -214,7 +214,7 @@ module.exports = (srf, logger) => { if (matches.length) { /* we have one or more matches. Now check for one with a provisioned phone number matching the DID */ const vc_sids = matches.map((m) => `'${m.voip_carrier_sid}'`).join(','); - const did = normalizeDID(req.calledNumber); + const did = normalizeDID(req.calledNumber) || 'anonymous'; const sql = `SELECT * FROM phone_numbers WHERE number = '${did}' AND voip_carrier_sid IN (${vc_sids})`; logger.debug({matches, sql, did, vc_sids}, 'looking up DID');