mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
bugfix #220 (config w/ bargein enable followed later in flow w bargein disable)
This commit is contained in:
@@ -245,7 +245,9 @@ module.exports = function(srf, logger) {
|
|||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const {call_hook, call_status_hook, ...appInfo} = app; // mask sensitive data like user/pass on webhook
|
const {call_hook, call_status_hook, ...appInfo} = app; // mask sensitive data like user/pass on webhook
|
||||||
logger.info({app: appInfo}, `retrieved application for incoming call to ${req.locals.calledNumber}`);
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const {requestor, notifier, ...loggable} = appInfo;
|
||||||
|
logger.info({app: loggable}, `retrieved application for incoming call to ${req.locals.calledNumber}`);
|
||||||
req.locals.callInfo = new CallInfo({
|
req.locals.callInfo = new CallInfo({
|
||||||
req,
|
req,
|
||||||
app: app2,
|
app: app2,
|
||||||
|
|||||||
@@ -471,10 +471,10 @@ class CallSession extends Emitter {
|
|||||||
this.backgroundGatherTask = makeTask(this.logger, t[0]);
|
this.backgroundGatherTask = makeTask(this.logger, t[0]);
|
||||||
this._bargeInEnabled = true;
|
this._bargeInEnabled = true;
|
||||||
this.backgroundGatherTask
|
this.backgroundGatherTask
|
||||||
.once('dtmf', this._clearTasks.bind(this))
|
.once('dtmf', this._clearTasks.bind(this, this.backgroundGatherTask))
|
||||||
.once('vad', this._clearTasks.bind(this))
|
.once('vad', this._clearTasks.bind(this, this.backgroundGatherTask))
|
||||||
.once('transcription', this._clearTasks.bind(this))
|
.once('transcription', this._clearTasks.bind(this, this.backgroundGatherTask))
|
||||||
.once('timeout', this._clearTasks.bind(this));
|
.once('timeout', this._clearTasks.bind(this, this.backgroundGatherTask));
|
||||||
this.logger.info({gather}, 'CallSession:enableBotMode - starting background gather');
|
this.logger.info({gather}, 'CallSession:enableBotMode - starting background gather');
|
||||||
const resources = await this._evaluatePreconditions(this.backgroundGatherTask);
|
const resources = await this._evaluatePreconditions(this.backgroundGatherTask);
|
||||||
const {span, ctx} = this.rootSpan.startChildSpan(`background-gather:${this.backgroundGatherTask.summary}`);
|
const {span, ctx} = this.rootSpan.startChildSpan(`background-gather:${this.backgroundGatherTask.summary}`);
|
||||||
@@ -1037,14 +1037,32 @@ class CallSession extends Emitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kill() {
|
kill(onBackgroundGatherBargein = false) {
|
||||||
if (this.isConfirmCallSession) this.logger.debug('CallSession:kill (ConfirmSession)');
|
if (this.isConfirmCallSession) this.logger.debug('CallSession:kill (ConfirmSession)');
|
||||||
else this.logger.info('CallSession:kill');
|
else this.logger.info('CallSession:kill');
|
||||||
if (this.currentTask) {
|
if (this.currentTask) {
|
||||||
this.currentTask.kill(this);
|
this.currentTask.kill(this);
|
||||||
this.currentTask = null;
|
this.currentTask = null;
|
||||||
}
|
}
|
||||||
this.tasks = [];
|
if (onBackgroundGatherBargein) {
|
||||||
|
/* search for a config with bargein disabled */
|
||||||
|
while (this.tasks.length) {
|
||||||
|
const t = this.tasks[0];
|
||||||
|
if (t.name === TaskName.Config && t.bargeIn?.enable === false) {
|
||||||
|
/* found it, clear to that point and remove the disable
|
||||||
|
because we likely already received a partial transcription
|
||||||
|
and we don't want to kill the background gather before we
|
||||||
|
get the full transcription.
|
||||||
|
*/
|
||||||
|
delete t.bargeIn.enable;
|
||||||
|
this._bargeInEnabled = false;
|
||||||
|
this.logger.info('CallSession:kill - found bargein disabled in the stack, clearing to that point');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.tasks.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else this.tasks = [];
|
||||||
this.taskIdx = 0;
|
this.taskIdx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1664,11 +1682,12 @@ class CallSession extends Emitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_clearTasks(evt) {
|
_clearTasks(backgroundGather, evt) {
|
||||||
if (this.requestor instanceof WsRequestor) {
|
if (this.requestor instanceof WsRequestor && !backgroundGather.cleared) {
|
||||||
this.logger.info({evt}, 'CallSession:_clearTasks on event from background gather');
|
this.logger.info({evt}, 'CallSession:_clearTasks on event from background gather');
|
||||||
try {
|
try {
|
||||||
this.kill();
|
backgroundGather.cleared = true;
|
||||||
|
this.kill(true);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user