This commit is contained in:
Dave Horton
2020-01-29 16:46:38 -05:00
parent 8487bb0571
commit 44a1b45357
7 changed files with 20 additions and 24 deletions

View File

@@ -3,13 +3,15 @@ require('request-debug')(request);
const retrieveApp = require('./retrieve-app');
function hooks(logger, callInfo) {
function actionHook(hook, obj, expectResponse = true) {
logger.debug({callInfo}, 'creating action hook');
function actionHook(hook, obj = {}, expectResponse = true) {
const method = hook.method.toUpperCase();
const auth = (hook.username && hook.password) ?
{username: hook.username, password: hook.password} :
null;
const data = Object.assign({}, obj, callInfo);
logger.debug({data}, `actionhook sending to ${hook.url}`);
if ('GET' === method) {
// remove customer data - only for POSTs since it might be quite complex
delete data.customerData;
@@ -20,8 +22,8 @@ function hooks(logger, callInfo) {
json: 'POST' === method || expectResponse
};
if (auth) obj.auth = auth;
if ('POST' === method) obj.body = data;
else obj.qs = data;
if ('POST' === method) opts.body = data;
else opts.qs = data;
return new Promise((resolve, reject) => {
request(opts, (err, response, body) => {

View File

@@ -95,6 +95,7 @@ class SingleDialer extends Emitter {
* (a) create a logger for this call
* (b) augment this.callInfo with additional call info
*/
this.logger.debug(`call sent, creating CallInfo parentCallInfo is CallInfo? ${this.parentCallInfo instanceof CallInfo}`);
this.callInfo = new CallInfo({
direction: CallDirection.Outbound,
parentCallInfo: this.parentCallInfo,
@@ -221,7 +222,7 @@ class SingleDialer extends Emitter {
_notifyCallStatusChange({callStatus, sipStatus}) {
this.logger.debug(`SingleDialer:_notifyCallStatusChange: ${callStatus} ${sipStatus}`);
this.callInfo.updateStatus(callStatus, sipStatus);
this.callInfo.updateCallStatus(callStatus, sipStatus);
try {
this.notifyHook(this.application.call_status_hook);
} catch (err) {