added initial support for REST-initiated outdials

This commit is contained in:
Dave Horton
2020-02-01 16:16:00 -05:00
parent 44a1b45357
commit 2525b8c70a
28 changed files with 985 additions and 127 deletions

View File

@@ -1,6 +1,6 @@
//const debug = require('debug')('jambonz:feature-server');
const uuidv4 = require('uuid/v4');
const {CallStatus, CallDirection} = require('./utils/constants');
const {CallDirection} = require('./utils/constants');
const CallInfo = require('./session/call-info');
const retrieveApp = require('./utils/retrieve-app');
const parseUrl = require('parse-url');
@@ -71,7 +71,7 @@ module.exports = function(srf, logger) {
const logger = req.locals.logger;
const app = req.locals.application;
const call_hook = app.call_hook;
const method = (call_hook.method || 'POST').toUpperCase();
const method = call_hook.method.toUpperCase();
let auth;
if (call_hook.username && call_hook.password) {
auth = {username: call_hook.username, password: call_hook.password};
@@ -81,7 +81,8 @@ module.exports = function(srf, logger) {
const myPort = u.port ? `:${u.port}` : '';
app.originalRequest = {
baseUrl: `${u.protocol}://${u.resource}${myPort}`,
auth
auth,
method
};
logger.debug({url: call_hook.url, method}, 'invokeWebCallback');
const obj = Object.assign({}, req.locals.callInfo);
@@ -91,8 +92,8 @@ module.exports = function(srf, logger) {
app.tasks = await retrieveApp(logger, call_hook.url, method, auth, obj);
next();
} catch (err) {
logger.error(err, 'Error retrieving or parsing application');
res.send(500);
logger.info(`Error retrieving or parsing application: ${err.message}`);
res.send(480, {headers: {'X-Reason': err.message}});
}
}