mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
bugfix: if enqeue task is killed because it is being replaced with new app supplied by LCC, ignore any app returned from the actionHook as LCC takes precedence
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const Emitter = require('events');
|
const Emitter = require('events');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const {CallDirection, TaskPreconditions, CallStatus, TaskName} = require('../utils/constants');
|
const {CallDirection, TaskPreconditions, CallStatus, TaskName, KillReason} = require('../utils/constants');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const sessionTracker = require('./session-tracker');
|
const sessionTracker = require('./session-tracker');
|
||||||
@@ -351,7 +351,7 @@ class CallSession extends Emitter {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* we started a new app on the child leg, but nothing given for parent so hang him up */
|
/* we started a new app on the child leg, but nothing given for parent so hang him up */
|
||||||
this.currentTask.kill();
|
this.currentTask.kill(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ class CallSession extends Emitter {
|
|||||||
this.logger.info({tasks: listTaskNames(tasks)},
|
this.logger.info({tasks: listTaskNames(tasks)},
|
||||||
`CallSession:replaceApplication reset with ${tasks.length} new tasks, stack depth is ${this.stackIdx}`);
|
`CallSession:replaceApplication reset with ${tasks.length} new tasks, stack depth is ${this.stackIdx}`);
|
||||||
if (this.currentTask) {
|
if (this.currentTask) {
|
||||||
this.currentTask.kill();
|
this.currentTask.kill(this, KillReason.Replaced);
|
||||||
this.currentTask = null;
|
this.currentTask = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -497,7 +497,7 @@ class CallSession extends Emitter {
|
|||||||
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.currentTask.kill(this);
|
||||||
this.currentTask = null;
|
this.currentTask = null;
|
||||||
}
|
}
|
||||||
this.tasks = [];
|
this.tasks = [];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const Emitter = require('events');
|
|||||||
const ConfirmCallSession = require('../session/confirm-call-session');
|
const ConfirmCallSession = require('../session/confirm-call-session');
|
||||||
const normalizeJambones = require('../utils/normalize-jambones');
|
const normalizeJambones = require('../utils/normalize-jambones');
|
||||||
const makeTask = require('./make_task');
|
const makeTask = require('./make_task');
|
||||||
const {TaskName, TaskPreconditions, QueueResults} = require('../utils/constants');
|
const {TaskName, TaskPreconditions, QueueResults, KillReason} = require('../utils/constants');
|
||||||
const bent = require('bent');
|
const bent = require('bent');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
@@ -61,10 +61,10 @@ class TaskEnqueue extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async kill(cs) {
|
async kill(cs, reason) {
|
||||||
super.kill(cs);
|
super.kill(cs);
|
||||||
this.logger.info(`TaskEnqueue:kill ${this.queueName}`);
|
this.logger.info(`TaskEnqueue:kill ${this.queueName}`);
|
||||||
this.emitter.emit('kill');
|
this.emitter.emit('kill', reason || KillReason.Hangup);
|
||||||
this.notifyTaskDone();
|
this.notifyTaskDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class TaskEnqueue extends Task {
|
|||||||
queueTime: getElapsedTime(this.waitStartTime),
|
queueTime: getElapsedTime(this.waitStartTime),
|
||||||
queueResult: this.state
|
queueResult: this.state
|
||||||
};
|
};
|
||||||
await super.performAction(params);
|
await super.performAction(params, this.killReason !== KillReason.Replaced);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,18 +119,20 @@ class TaskEnqueue extends Task {
|
|||||||
resolve(this._doBridge(cs, dlg, ep));
|
resolve(this._doBridge(cs, dlg, ep));
|
||||||
})
|
})
|
||||||
.once('kill', async() => {
|
.once('kill', async() => {
|
||||||
try {
|
|
||||||
const members = await this._removeFromQueue(cs);
|
|
||||||
|
|
||||||
/* invoke account-level webhook for queue event notifications */
|
/* invoke account-level webhook for queue event notifications */
|
||||||
cs.performQueueWebhook({
|
if (!this.dequeued) {
|
||||||
event: 'leave',
|
try {
|
||||||
queue: this.data.name,
|
const members = await this._removeFromQueue(cs);
|
||||||
length: members,
|
cs.performQueueWebhook({
|
||||||
leaveReason: 'abandoned',
|
event: 'leave',
|
||||||
leaveTime: Date.now()
|
queue: this.data.name,
|
||||||
});
|
length: members,
|
||||||
} catch (err) {}
|
leaveReason: 'abandoned',
|
||||||
|
leaveTime: Date.now()
|
||||||
|
});
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
|
||||||
if (this._playSession) {
|
if (this._playSession) {
|
||||||
this.logger.debug('killing waitUrl');
|
this.logger.debug('killing waitUrl');
|
||||||
@@ -236,8 +238,9 @@ class TaskEnqueue extends Task {
|
|||||||
ep.unbridge().catch((err) => {});
|
ep.unbridge().catch((err) => {});
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.on('kill', () => {
|
.on('kill', (reason) => {
|
||||||
this.logger.info('TaskEnqueue:_bridgeLocal ending with hangup from enqeue party');
|
this.killReason = reason;
|
||||||
|
this.logger.info(`TaskEnqueue:_bridgeLocal ending with ${this.killReason}`);
|
||||||
ep.unbridge().catch((err) => {});
|
ep.unbridge().catch((err) => {});
|
||||||
|
|
||||||
// notify partner that we dropped
|
// notify partner that we dropped
|
||||||
@@ -273,6 +276,7 @@ class TaskEnqueue extends Task {
|
|||||||
try {
|
try {
|
||||||
const {lengthOfList} = cs.srf.locals.dbHelpers;
|
const {lengthOfList} = cs.srf.locals.dbHelpers;
|
||||||
const members = await lengthOfList(this.queueName);
|
const members = await lengthOfList(this.queueName);
|
||||||
|
this.dequeued = true;
|
||||||
|
|
||||||
cs.performQueueWebhook({
|
cs.performQueueWebhook({
|
||||||
event: 'leave',
|
event: 'leave',
|
||||||
|
|||||||
@@ -92,6 +92,10 @@
|
|||||||
"Hangup": "hangup",
|
"Hangup": "hangup",
|
||||||
"Timeout": "timeout"
|
"Timeout": "timeout"
|
||||||
},
|
},
|
||||||
|
"KillReason": {
|
||||||
|
"Hangup": "hangup",
|
||||||
|
"Replaced": "replaced"
|
||||||
|
},
|
||||||
"MAX_SIMRINGS": 10,
|
"MAX_SIMRINGS": 10,
|
||||||
"BONG_TONE": "tone_stream://v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1400,0,350,440)"
|
"BONG_TONE": "tone_stream://v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1400,0,350,440)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user