feat: lcr added (#80)

* feat: lcr added

* fix: await for async

* fix: add lookupCarrierByAccountLcr to locals

* fix typo

* fix typo

* fix typo
This commit is contained in:
Hoan Luu Huu
2023-05-08 09:06:37 -04:00
committed by GitHub
parent e00379d119
commit 039a60c1b7
4 changed files with 26 additions and 15 deletions
+4 -2
View File
@@ -44,7 +44,8 @@ const {
lookupAccountCapacitiesBySid,
lookupSipGatewaysByCarrier,
lookupCarrierBySid,
queryCallLimits
queryCallLimits,
lookupCarrierByAccountLcr
} = require('@jambonz/db-helpers')({
host: process.env.JAMBONES_MYSQL_HOST,
port: process.env.JAMBONES_MYSQL_PORT || 3306,
@@ -90,7 +91,8 @@ srf.locals = {...srf.locals,
lookupAccountCapacitiesBySid,
lookupSipGatewaysByCarrier,
lookupCarrierBySid,
queryCallLimits
queryCallLimits,
lookupCarrierByAccountLcr
},
realtimeDbHelpers: {
createHash,
+12 -3
View File
@@ -83,10 +83,15 @@ class CallSession extends Emitter {
this.decrKey = req.srf.locals.realtimeDbHelpers.decrKey;
const {performLcr, lookupCarrierBySid, lookupSipGatewaysByCarrier} = this.srf.locals.dbHelpers;
const {performLcr,
lookupCarrierBySid,
lookupSipGatewaysByCarrier,
lookupCarrierByAccountLcr
} = this.srf.locals.dbHelpers;
this.performLcr = performLcr;
this.lookupCarrierBySid = lookupCarrierBySid;
this.lookupSipGatewaysByCarrier = lookupSipGatewaysByCarrier;
this.lookupCarrierByAccountLcr = lookupCarrierByAccountLcr;
this._mediaReleased = false;
}
@@ -212,10 +217,14 @@ class CallSession extends Emitter {
};
}
else {
debug('calling lcr');
try {
/* was a specific carrier requested */
const voip_carrier_sid = this.req.get('X-Requested-Carrier-Sid');
let voip_carrier_sid = this.req.get('X-Requested-Carrier-Sid');
const account_sid = this.req.get('X-Account-Sid');
if (!voip_carrier_sid && account_sid) {
debug('calling lcr');
voip_carrier_sid = await this.lookupCarrierByAccountLcr(account_sid, this.req.calledNumber);
}
if (voip_carrier_sid) {
const vc = await this.lookupCarrierBySid(voip_carrier_sid);
const gateways = await this.lookupSipGatewaysByCarrier(voip_carrier_sid);
+9 -9
View File
@@ -9,7 +9,7 @@
"version": "v0.8.2",
"license": "MIT",
"dependencies": {
"@jambonz/db-helpers": "^0.7.4",
"@jambonz/db-helpers": "^0.7.8",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/mw-registrar": "0.2.2",
"@jambonz/realtimedb-helpers": "^0.7.0",
@@ -573,12 +573,12 @@
}
},
"node_modules/@jambonz/db-helpers": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.4.tgz",
"integrity": "sha512-sR3f+RpCrSWkZ7E8qjO9/Fgsa8aBuNkm4Ubr6To0K9GDsE9rb9dsYUGpXN/0f9CGn7jc4icc53OBkt+iM2PbCw==",
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.9.tgz",
"integrity": "sha512-JajIJSPXW0OTjVprDwTH8/yU/qhHY1XkXe6f5PRh0kvRt42AmYggcGKqgivUkY1seR/GVCnQccDcIA2ZEdvDUg==",
"dependencies": {
"cidr-matcher": "^2.1.1",
"debug": "^4.3.3",
"debug": "^4.3.4",
"mysql2": "^2.3.3",
"node-object-hash": "^2.3.10",
"uuid": "^8.3.2"
@@ -5235,12 +5235,12 @@
"dev": true
},
"@jambonz/db-helpers": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.4.tgz",
"integrity": "sha512-sR3f+RpCrSWkZ7E8qjO9/Fgsa8aBuNkm4Ubr6To0K9GDsE9rb9dsYUGpXN/0f9CGn7jc4icc53OBkt+iM2PbCw==",
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.9.tgz",
"integrity": "sha512-JajIJSPXW0OTjVprDwTH8/yU/qhHY1XkXe6f5PRh0kvRt42AmYggcGKqgivUkY1seR/GVCnQccDcIA2ZEdvDUg==",
"requires": {
"cidr-matcher": "^2.1.1",
"debug": "^4.3.3",
"debug": "^4.3.4",
"mysql2": "^2.3.3",
"node-object-hash": "^2.3.10",
"uuid": "^8.3.2"
+1 -1
View File
@@ -27,7 +27,7 @@
"jslint": "eslint app.js lib"
},
"dependencies": {
"@jambonz/db-helpers": "^0.7.4",
"@jambonz/db-helpers": "^0.7.8",
"@jambonz/realtimedb-helpers": "^0.7.0",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/mw-registrar": "0.2.2",