mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
send queue leave webhook when dequeued
This commit is contained in:
@@ -110,7 +110,8 @@ class TaskDequeue extends Task {
|
|||||||
event: 'dequeue',
|
event: 'dequeue',
|
||||||
dequeueSipAddress: cs.srf.locals.localSipAddress,
|
dequeueSipAddress: cs.srf.locals.localSipAddress,
|
||||||
epUuid: ep.uuid,
|
epUuid: ep.uuid,
|
||||||
notifyUrl: getUrl(cs)
|
notifyUrl: getUrl(cs),
|
||||||
|
dequeuer: cs.callInfo.toJSON()
|
||||||
});
|
});
|
||||||
this.logger.info(`TaskDequeue:_dequeueUrl successfully sent POST to ${url}`);
|
this.logger.info(`TaskDequeue:_dequeueUrl successfully sent POST to ${url}`);
|
||||||
bridgeTimer = setTimeout(() => reject(new Error('bridge timeout')), 20000);
|
bridgeTimer = setTimeout(() => reject(new Error('bridge timeout')), 20000);
|
||||||
|
|||||||
@@ -263,12 +263,26 @@ class TaskEnqueue extends Task {
|
|||||||
* @param {string} opts.epUuid uuid of the endpoint we need to bridge to
|
* @param {string} opts.epUuid uuid of the endpoint we need to bridge to
|
||||||
* @param {string} opts.dequeueSipAddress ip:port of the feature server hosting the other call
|
* @param {string} opts.dequeueSipAddress ip:port of the feature server hosting the other call
|
||||||
*/
|
*/
|
||||||
notifyQueueEvent(cs, opts) {
|
async notifyQueueEvent(cs, opts) {
|
||||||
if (opts.event === 'dequeue') {
|
if (opts.event === 'dequeue') {
|
||||||
if (this.bridgeNow) return;
|
if (this.bridgeNow) return;
|
||||||
this.logger.info({opts}, `TaskEnqueue:notifyDequeueEvent: leaving ${this.queueName} because someone wants me`);
|
this.logger.info({opts}, `TaskEnqueue:notifyDequeueEvent: leaving ${this.queueName} because someone wants me`);
|
||||||
assert(opts.dequeueSipAddress && opts.epUuid && opts.notifyUrl);
|
assert(opts.dequeueSipAddress && opts.epUuid && opts.notifyUrl);
|
||||||
this.emitter.emit('dequeue', opts);
|
this.emitter.emit('dequeue', opts);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const {lengthOfList} = cs.srf.locals.dbHelpers;
|
||||||
|
const members = await lengthOfList(this.queueName);
|
||||||
|
|
||||||
|
cs.performQueueWebhook({
|
||||||
|
event: 'leave',
|
||||||
|
queue: this.data.name,
|
||||||
|
length: Math.max(members - 1, 0),
|
||||||
|
leaveReason: 'dequeued',
|
||||||
|
leaveTime: Date.now(),
|
||||||
|
dequeuer: opts.dequeuer
|
||||||
|
});
|
||||||
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
else if (opts.event === 'hangup') {
|
else if (opts.event === 'hangup') {
|
||||||
this.emitter.emit('hangup');
|
this.emitter.emit('hangup');
|
||||||
|
|||||||
Reference in New Issue
Block a user