mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-01-24 22:37:51 +00:00
support device call to app
This commit is contained in:
6
app.js
6
app.js
@@ -80,7 +80,8 @@ const {
|
||||
lookupAccountBySid,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits,
|
||||
lookupClientByAccountAndUsername
|
||||
lookupClientByAccountAndUsername,
|
||||
lookupAppBySid
|
||||
} = require('@jambonz/db-helpers')({
|
||||
host: process.env.JAMBONES_MYSQL_HOST,
|
||||
port: process.env.JAMBONES_MYSQL_PORT || 3306,
|
||||
@@ -130,7 +131,8 @@ srf.locals = {...srf.locals,
|
||||
lookupAccountBySipRealm,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits,
|
||||
lookupClientByAccountAndUsername
|
||||
lookupClientByAccountAndUsername,
|
||||
lookupAppBySid
|
||||
},
|
||||
realtimeDbHelpers: {
|
||||
createSet,
|
||||
|
||||
@@ -28,7 +28,8 @@ module.exports = function(srf, logger) {
|
||||
lookupAccountBySipRealm,
|
||||
lookupAccountBySid,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits
|
||||
queryCallLimits,
|
||||
lookupAppBySid
|
||||
} = srf.locals.dbHelpers;
|
||||
const {stats, writeCdrs} = srf.locals;
|
||||
|
||||
@@ -196,11 +197,20 @@ module.exports = function(srf, logger) {
|
||||
res.send(404);
|
||||
return req.srf.endSession(req);
|
||||
}
|
||||
let deviceAppSid = null;
|
||||
if (req.has('X-Application-Sid')) {
|
||||
// Call from registered device to test application.
|
||||
const appSid = req.get('X-Application-Sid');
|
||||
const app = await lookupAppBySid(appSid);
|
||||
if (app && app.account_sid === account.account_sid) {
|
||||
deviceAppSid = app.application_sid;
|
||||
}
|
||||
}
|
||||
req.locals = {
|
||||
service_provider_sid: account.service_provider_sid,
|
||||
account_sid: account.account_sid,
|
||||
account,
|
||||
application_sid: account.device_calling_application_sid,
|
||||
application_sid: deviceAppSid || account.device_calling_application_sid,
|
||||
webhook_secret: account.webhook_secret,
|
||||
realm: uri.host,
|
||||
...(account.registration_hook && {
|
||||
|
||||
Reference in New Issue
Block a user