mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
Fix/env vars rest dial (#1225)
* rest dial needs to support env vars * wip
This commit is contained in:
@@ -12,6 +12,7 @@ const HttpRequestor = require('../../utils/http-requestor');
|
||||
const WsRequestor = require('../../utils/ws-requestor');
|
||||
const RootSpan = require('../../utils/call-tracer');
|
||||
const dbUtils = require('../../utils/db-utils');
|
||||
const { decrypt } = require('../../utils/encrypt-decrypt');
|
||||
const { mergeSdpMedia, extractSdpMedia } = require('../../utils/sdp-utils');
|
||||
const { createCallSchema, customSanitizeFunction } = require('../schemas/create-call');
|
||||
const { selectHostPort } = require('../../utils/network');
|
||||
@@ -212,6 +213,13 @@ router.post('/',
|
||||
* we merge the inbound call application,
|
||||
* with the provided app params from the request body
|
||||
*/
|
||||
try {
|
||||
if (application?.env_vars && Object.keys(application.env_vars).length > 0) {
|
||||
restDial.env_vars = JSON.parse(decrypt(application.env_vars));
|
||||
}
|
||||
} catch (err) {
|
||||
logger.info({err}, 'Unable to set env_vars');
|
||||
}
|
||||
const app = {
|
||||
...application,
|
||||
...req.body
|
||||
@@ -224,7 +232,7 @@ router.post('/',
|
||||
if ('WS' === app.call_hook?.method || /^wss?:/.test(app.call_hook.url)) {
|
||||
logger.debug({call_hook: app.call_hook}, 'creating websocket for call hook');
|
||||
app.requestor = new WsRequestor(logger, account.account_sid, app.call_hook, account.webhook_secret) ;
|
||||
if (app.call_hook.url === app.call_status_hook.url || !app.call_status_hook?.url) {
|
||||
if (app.call_hook.url === app.call_status_hook?.url || !app.call_status_hook?.url) {
|
||||
logger.debug('reusing websocket for call status hook');
|
||||
app.notifier = app.requestor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user