initial support for conference and queues

This commit is contained in:
Dave Horton
2020-05-06 15:27:24 -04:00
parent 419c5ea9fd
commit a0508a2494
18 changed files with 711 additions and 68 deletions

View File

@@ -1,4 +1,5 @@
const Emitter = require('events');
const uuidv4 = require('uuid/v4');
const debug = require('debug')('jambonz:feature-server');
const assert = require('assert');
const {TaskPreconditions} = require('../utils/constants');
@@ -98,6 +99,38 @@ class Task extends Emitter {
}
}
async transferCallToFeatureServer(cs, sipAddress, opts) {
const uuid = uuidv4();
const {addKey} = cs.srf.locals.dbHelpers;
const obj = Object.assign({}, cs.application);
delete obj.requestor;
delete obj.notifier;
obj.tasks = cs.getRemainingTaskData();
if (opts && obj.tasks.length > 1) obj.tasks[0]._ = opts;
this.logger.debug({obj}, 'Task:_doRefer');
const success = await addKey(uuid, JSON.stringify(obj), 30);
if (!success) {
this.logger.info(`Task:_doRefer failed storing task data before REFER for ${this.queueName}`);
return;
}
try {
this.logger.info(`Task:_doRefer: referring call to ${sipAddress} for ${this.queueName}`);
this.callMoved = true;
const success = await cs.referCall(`sip:context-${uuid}@${sipAddress}`);
if (!success) {
this.callMoved = false;
this.logger.info('Task:_doRefer REFER failed');
return success;
}
this.logger.info('Task:_doRefer REFER succeeded');
return success;
} catch (err) {
this.logger.error(err, 'Task:_doRefer error');
}
}
/**
* validate that the JSON task description is valid
* @param {string} name - verb name