This commit is contained in:
Dave Horton
2020-01-17 09:25:41 -05:00
parent 0d4c1d9d8c
commit c1049943e1
5 changed files with 31 additions and 84 deletions

View File

@@ -10,7 +10,9 @@ function makeTask(logger, obj) {
const name = keys[0];
const data = obj[name];
logger.debug(data, `makeTask: ${name}`);
if (typeof data !== 'object') throw errBadInstruction;
if (typeof data !== 'object') {
throw errBadInstruction;
}
Task.validate(name, data);
switch (name) {
case TaskName.SipDecline:

View File

@@ -38,6 +38,7 @@ class TaskSay extends Task {
}
kill() {
super.kill();
if (this.ep.connected && !this.sayComplete) {
this.logger.debug('TaskSay:kill - killing audio');
this.ep.api('uuid_break', this.ep.uuid).catch((err) => this.logger.info(err, 'Error killing audio'));

View File

@@ -4,12 +4,7 @@ function normalizeJambones(logger, obj) {
const document = [];
for (const tdata of obj) {
if (typeof tdata !== 'object') throw new Error('invalid JSON: jambones docs must be array of objects');
if (Object.keys(tdata).length === 1) {
// {'say': {..}}
logger.debug(`pushing ${JSON.stringify(tdata)}`);
document.push(tdata);
}
else if ('verb' in tdata) {
if ('verb' in tdata) {
// {verb: 'say', text: 'foo..bar'..}
const name = tdata.verb;
const o = {};
@@ -20,6 +15,11 @@ function normalizeJambones(logger, obj) {
o2[name] = o;
document.push(o2);
}
else if (Object.keys(tdata).length === 1) {
// {'say': {..}}
logger.debug(`pushing ${JSON.stringify(tdata)}`);
document.push(tdata);
}
else {
logger.info(tdata, `invalid JSON: invalid verb form, numkeys ${Object.keys(tdata).length}`);
throw new Error('invalid JSON: invalid verb form');