standardize on passing .query args as array (#99)

This commit is contained in:
Dave Horton
2023-05-22 09:56:48 -04:00
committed by GitHub
parent 54d9044937
commit f6e071f31e
3 changed files with 15 additions and 15 deletions

View File

@@ -137,12 +137,12 @@ module.exports = (srf, logger) => {
*/
/* get all the carriers and gateways for the account owning this sip realm */
const [gwAcc] = await pp.query(sqlSelectAllCarriersForAccountByRealm, uri.host);
const [gwAcc] = await pp.query(sqlSelectAllCarriersForAccountByRealm, [uri.host]);
const [gwSP] = gwAcc.length ? [[]] : await pp.query(sqlSelectAllCarriersForSPByRealm, uri.host);
const gw = gwAcc.concat(gwSP);
const selected = gw.find(gatewayMatchesSourceAddress.bind(null, req.source_address));
if (selected) {
const [a] = await pp.query(sqlAccountByRealm, uri.host);
const [a] = await pp.query(sqlAccountByRealm, [uri.host]);
if (0 === a.length) return failure;
return {
fromCarrier: true,
@@ -168,7 +168,7 @@ module.exports = (srf, logger) => {
//if the carrier is associated with an SP (which would mean we
//must see a dialed number in the To header, not the register username),
//then we need to look up the account based on the dialed number in the To header
const [a] = await pp.query(sqlAccountBySid, matches[0].account_sid);
const [a] = await pp.query(sqlAccountBySid, [[matches[0].account_sid]]);
if (0 === a.length) return failure;
logger.debug({matches}, `found registration carrier using ${uri.host} and ${uri.user}`);
return {
@@ -247,7 +247,7 @@ module.exports = (srf, logger) => {
}
else if (accountLevelGateways.length === 1) {
const [accounts] = await pp.query('SELECT * from accounts where account_sid = ?',
accountLevelGateways[0].account_sid);
[accountLevelGateways[0].account_sid]);
return {
fromCarrier: true,
gateway: accountLevelGateways[0],
@@ -262,11 +262,11 @@ module.exports = (srf, logger) => {
- way of knowing which account this is for
*/
const [r] = await pp.query('SELECT count(*) as count from accounts where service_provider_sid = ?',
matches[0].service_provider_sid);
[matches[0].service_provider_sid]);
if (r[0].count === 0 || r[0].count > 1) return {fromCarrier: true};
else {
const [accounts] = await pp.query('SELECT * from accounts where service_provider_sid = ?',
matches[0].service_provider_sid);
[matches[0].service_provider_sid]);
return {
fromCarrier: true,
gateway: matches[0],
@@ -288,7 +288,7 @@ module.exports = (srf, logger) => {
/* we have a route for this phone number and carrier combination */
const gateway = matches.find((m) => m.voip_carrier_sid === r[0].voip_carrier_sid);
const [accounts] = await pp.query(sqlAccountBySid, r[0].account_sid);
const [accounts] = await pp.query(sqlAccountBySid, [r[0].account_sid]);
assert(accounts.length);
return {
fromCarrier: true,

14
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "0.8.3",
"license": "MIT",
"dependencies": {
"@jambonz/db-helpers": "^0.7.9",
"@jambonz/db-helpers": "^0.8.1",
"@jambonz/http-authenticator": "^0.2.2",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.7.2",
@@ -595,9 +595,9 @@
}
},
"node_modules/@jambonz/db-helpers": {
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.9.tgz",
"integrity": "sha512-JajIJSPXW0OTjVprDwTH8/yU/qhHY1XkXe6f5PRh0kvRt42AmYggcGKqgivUkY1seR/GVCnQccDcIA2ZEdvDUg==",
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.8.1.tgz",
"integrity": "sha512-pc5TRAYnb89oyD5Ncy9Ik+v/tBqQcNOthbDwaX1OJyGRhPdolgs4YvOTpc0KpSqx7TDjKPS9n5MlqOFWgyDbTA==",
"dependencies": {
"cidr-matcher": "^2.1.1",
"debug": "^4.3.4",
@@ -5735,9 +5735,9 @@
"dev": true
},
"@jambonz/db-helpers": {
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.9.tgz",
"integrity": "sha512-JajIJSPXW0OTjVprDwTH8/yU/qhHY1XkXe6f5PRh0kvRt42AmYggcGKqgivUkY1seR/GVCnQccDcIA2ZEdvDUg==",
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.8.1.tgz",
"integrity": "sha512-pc5TRAYnb89oyD5Ncy9Ik+v/tBqQcNOthbDwaX1OJyGRhPdolgs4YvOTpc0KpSqx7TDjKPS9n5MlqOFWgyDbTA==",
"requires": {
"cidr-matcher": "^2.1.1",
"debug": "^4.3.4",

View File

@@ -25,7 +25,7 @@
"jslint": "eslint app.js lib"
},
"dependencies": {
"@jambonz/db-helpers": "^0.7.9",
"@jambonz/db-helpers": "^0.8.1",
"@jambonz/http-authenticator": "^0.2.2",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.7.2",