mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
changes for updateCall pause/resume listen audio
This commit is contained in:
@@ -6,7 +6,7 @@ const retrieveApp = require('./utils/retrieve-app');
|
||||
const parseUrl = require('parse-url');
|
||||
|
||||
module.exports = function(srf, logger) {
|
||||
const {lookupAppByPhoneNumber} = srf.locals.dbHelpers;
|
||||
const {lookupAppByPhoneNumber, lookupApplicationBySid} = srf.locals.dbHelpers;
|
||||
|
||||
function initLocals(req, res, next) {
|
||||
const callSid = uuidv4();
|
||||
@@ -14,6 +14,11 @@ module.exports = function(srf, logger) {
|
||||
callSid,
|
||||
logger: logger.child({callId: req.get('Call-ID'), callSid})
|
||||
};
|
||||
if (req.has('X-Application-Sid')) {
|
||||
const application_sid = req.get('X-Application-Sid');
|
||||
req.locals.logger.debug(`got application from X-Application-Sid header: ${application_sid}`);
|
||||
req.locals.application_sid = application_sid;
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -44,7 +49,13 @@ module.exports = function(srf, logger) {
|
||||
async function retrieveApplication(req, res, next) {
|
||||
const logger = req.locals.logger;
|
||||
try {
|
||||
const app = await lookupAppByPhoneNumber(req.locals.calledNumber);
|
||||
let app;
|
||||
if (req.locals.application_sid) {
|
||||
app = await lookupApplicationBySid(req.locals.application_sid);
|
||||
}
|
||||
else {
|
||||
app = await lookupAppByPhoneNumber(req.locals.calledNumber);
|
||||
}
|
||||
if (!app || !app.call_hook || !app.call_hook.url) {
|
||||
logger.info(`rejecting call to ${req.locals.calledNumber}: no application or webhook url`);
|
||||
return res.send(480, {
|
||||
|
||||
Reference in New Issue
Block a user