remove config in favor of env vars, other major changes

This commit is contained in:
Dave Horton
2020-02-15 22:03:28 -05:00
parent 3d24ac1914
commit 3c89b7fd76
14 changed files with 162 additions and 113 deletions

View File

@@ -1,5 +1,4 @@
const Emitter = require('events');
const config = require('config');
const {CallDirection, TaskPreconditions, CallStatus, TaskName} = require('../utils/constants');
const moment = require('moment');
const assert = require('assert');
@@ -227,13 +226,11 @@ class CallSession extends Emitter {
* @param {object} [opts.call_hook] - new call_status_hook
*/
async _lccCallHook(opts) {
const tasks = await this.requestor(opts.call_hook, this.callInfo);
//TODO: if they gave us a call status hook, we should replace
//the existing one (or just remove this option altogether?)
this.logger.info({tasks}, 'CallSession:updateCall new task list');
this.replaceApplication(tasks);
const tasks = await this.requestor.request(opts.call_hook, this.callInfo);
if (tasks && tasks.length > 0) {
this.logger.info({tasks}, 'CallSession:updateCall new task list');
this.replaceApplication(normalizeJamones(this.logger, tasks).map((tdata) => makeTask(this.logger, tdata)));
}
}
/**
@@ -488,7 +485,7 @@ class CallSession extends Emitter {
async getMS() {
if (!this.ms) {
const mrf = this.srf.locals.mrf;
this.ms = await mrf.connect(config.get('freeswitch'));
this.ms = await mrf.connect(this.srf.locals.freeswitch);
}
return this.ms;
}
@@ -503,7 +500,7 @@ class CallSession extends Emitter {
// get a media server
if (!this.ms) {
this.ms = await mrf.connect(config.get('freeswitch'));
this.ms = await mrf.connect(this.srf.locals.freeswitch);
}
if (!this.ep) {
this.ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
@@ -534,6 +531,7 @@ class CallSession extends Emitter {
}
// update calls db
this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`);
this.updateCallStatus(this.callInfo, this.serviceUrl).catch((err) => this.logger.error(err, 'redis error'));
}
}