mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
fix error with createCall api
This commit is contained in:
6
app.js
6
app.js
@@ -29,7 +29,11 @@ const {
|
||||
// HTTP
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
app.locals.logger = logger;
|
||||
Object.assign(app.locals, {
|
||||
logger,
|
||||
srf
|
||||
});
|
||||
|
||||
const httpRoutes = require('./lib/http-routes');
|
||||
|
||||
const InboundCallSession = require('./lib/session/inbound-call-session');
|
||||
|
||||
@@ -7,24 +7,13 @@ const SipError = require('drachtio-srf').SipError;
|
||||
const sysError = require('./error');
|
||||
const Requestor = require('../../utils/requestor');
|
||||
|
||||
/**
|
||||
* Retrieve a connection to a drachtio server, lazily creating when first called
|
||||
*/
|
||||
function getSrfForOutdial(logger) {
|
||||
const {srf} = require('../../../');
|
||||
const {getSrf} = srf.locals;
|
||||
const srfForOutdial = getSrf();
|
||||
if (!srfForOutdial) throw new Error('no available feature servers for outbound call creation');
|
||||
return srfForOutdial;
|
||||
}
|
||||
|
||||
router.post('/', async(req, res) => {
|
||||
const logger = req.app.locals.logger;
|
||||
const {logger, srf} = req.app.locals;
|
||||
|
||||
logger.debug({body: req.body}, 'got createCall request');
|
||||
try {
|
||||
let uri, cs, to;
|
||||
const restDial = makeTask(logger, {'rest:dial': req.body});
|
||||
const srf = getSrfForOutdial(logger);
|
||||
const {getSBC, getFreeswitch} = srf.locals;
|
||||
const sbcAddress = getSBC();
|
||||
if (!sbcAddress) throw new Error('no available SBCs for outbound call creation');
|
||||
|
||||
Reference in New Issue
Block a user