more testing

This commit is contained in:
Dave Horton
2020-01-25 15:51:47 -05:00
parent 12d49a40a4
commit 0df1e44f15
9 changed files with 79 additions and 49 deletions

View File

@@ -1,13 +1,8 @@
const request = require('request');
//require('request-debug')(request);
const makeTask = require('../tasks/make_task');
const normalizeJamones = require('./normalize-jamones');
const debug = require('debug')('jambonz:feature-server');
const retrieveApp = require('./retrieve-app');
function hooks(logger, callAttributes) {
debug(`notifiers: callAttributes ${JSON.stringify(callAttributes)}`);
function actionHook(url, method, auth, opts, expectResponse = false) {
function actionHook(url, method, auth, opts, expectResponse = true) {
const params = Object.assign({}, callAttributes, opts);
let basicauth, qs, body;
if (auth && typeof auth === 'object' && Object.keys(auth) === 2) basicauth = auth;
@@ -21,12 +16,9 @@ function hooks(logger, callAttributes) {
logger.info(`actionHook error ${method} ${url}: ${err.message}`);
return reject(err);
}
if (body) {
if (body && expectResponse) {
logger.debug(body, `actionHook response ${method} ${url}`);
if (expectResponse) {
const tasks = normalizeJamones(logger, body).map((tdata) => makeTask(logger, tdata));
return resolve(tasks);
}
return resolve(retrieveApp(logger, body));
}
resolve(body);
});

View File

@@ -42,7 +42,7 @@ class SingleDialer extends Emitter {
switch (this.target.type) {
case 'phone':
assert(this.target.number);
uri = `sip:${this.opts.number}@${this.sbcAddress}`;
uri = `sip:${this.target.number}@${this.sbcAddress}`;
to = this.target.number;
break;
case 'user':
@@ -51,9 +51,9 @@ class SingleDialer extends Emitter {
to = this.target.name;
break;
case 'sip':
assert(this.target.uri);
uri = this.target.uri;
to = this.target.name;
assert(this.target.sipUri);
uri = this.target.sipUri;
to = this.target.sipUri;
break;
default:
// should have been caught by parser