mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-22 01:27:55 +00:00
fix error with createCall api
This commit is contained in:
6
app.js
6
app.js
@@ -29,7 +29,11 @@ const {
|
|||||||
// HTTP
|
// HTTP
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
app.locals.logger = logger;
|
Object.assign(app.locals, {
|
||||||
|
logger,
|
||||||
|
srf
|
||||||
|
});
|
||||||
|
|
||||||
const httpRoutes = require('./lib/http-routes');
|
const httpRoutes = require('./lib/http-routes');
|
||||||
|
|
||||||
const InboundCallSession = require('./lib/session/inbound-call-session');
|
const InboundCallSession = require('./lib/session/inbound-call-session');
|
||||||
|
|||||||
@@ -7,24 +7,13 @@ const SipError = require('drachtio-srf').SipError;
|
|||||||
const sysError = require('./error');
|
const sysError = require('./error');
|
||||||
const Requestor = require('../../utils/requestor');
|
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) => {
|
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');
|
logger.debug({body: req.body}, 'got createCall request');
|
||||||
try {
|
try {
|
||||||
let uri, cs, to;
|
let uri, cs, to;
|
||||||
const restDial = makeTask(logger, {'rest:dial': req.body});
|
const restDial = makeTask(logger, {'rest:dial': req.body});
|
||||||
const srf = getSrfForOutdial(logger);
|
|
||||||
const {getSBC, getFreeswitch} = srf.locals;
|
const {getSBC, getFreeswitch} = srf.locals;
|
||||||
const sbcAddress = getSBC();
|
const sbcAddress = getSBC();
|
||||||
if (!sbcAddress) throw new Error('no available SBCs for outbound call creation');
|
if (!sbcAddress) throw new Error('no available SBCs for outbound call creation');
|
||||||
|
|||||||
Reference in New Issue
Block a user