bugfix for enqueue and dial when these tasks are replaced by LCC

This commit is contained in:
Dave Horton
2021-06-29 11:04:12 -04:00
parent 9bd406fcba
commit 2b782bc5f3
2 changed files with 15 additions and 7 deletions

View File

@@ -1,6 +1,13 @@
const Task = require('./task');
const makeTask = require('./make_task');
const {CallStatus, CallDirection, TaskName, TaskPreconditions, MAX_SIMRINGS} = require('../utils/constants');
const {
CallStatus,
CallDirection,
TaskName,
TaskPreconditions,
MAX_SIMRINGS,
KillReason
} = require('../utils/constants');
const assert = require('assert');
const placeCall = require('../utils/place-outdial');
const sessionTracker = require('../session/session-tracker');
@@ -140,7 +147,7 @@ class TaskDial extends Task {
await this.awaitTaskDone();
this.logger.debug({callSid: this.cs.callSid}, 'Dial:exec task is done, sending actionHook if any');
await this.performAction(this.results);
await this.performAction(this.results, this.killReason !== KillReason.Replaced);
this._removeDtmfDetection(cs, this.epOther);
this._removeDtmfDetection(cs, this.ep);
} catch (err) {
@@ -149,8 +156,9 @@ class TaskDial extends Task {
}
}
async kill(cs) {
async kill(cs, reason) {
super.kill(cs);
this.killReason = reason || KillReason.Hangup;
this._removeDtmfDetection(this.cs, this.epOther);
this._removeDtmfDetection(this.cs, this.ep);
this.logger.debug({callSid: this.cs.callSid}, 'Dial:kill removed dtmf listeners');

View File

@@ -63,8 +63,9 @@ class TaskEnqueue extends Task {
async kill(cs, reason) {
super.kill(cs);
this.logger.info(`TaskEnqueue:kill ${this.queueName}`);
this.emitter.emit('kill', reason || KillReason.Hangup);
this.killReason = reason || KillReason.Hangup;
this.logger.info(`TaskEnqueue:kill ${this.queueName} with reason ${this.killReason}`);
this.emitter.emit('kill');
this.notifyTaskDone();
}
@@ -238,8 +239,7 @@ class TaskEnqueue extends Task {
ep.unbridge().catch((err) => {});
resolve();
})
.on('kill', (reason) => {
this.killReason = reason;
.on('kill', () => {
this.logger.info(`TaskEnqueue:_bridgeLocal ending with ${this.killReason}`);
ep.unbridge().catch((err) => {});