mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
more testing
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user