normalize things

This commit is contained in:
akirilyuk
2022-02-01 18:30:20 +01:00
parent 9657017669
commit 5389083107

View File

@@ -4,6 +4,7 @@ const makeTask = require('../make_task');
const { SocketClient } = require('@cognigy/socket-client');
const SpeechConfig = require('./speech-config');
const queue = require('queue');
const normalizeJambones = require('../utils/normalize-jambones');
const parseGallery = (obj = {}) => {
const {_default} = obj;
@@ -199,13 +200,22 @@ class Cognigy extends Task {
}
_makeReferTask(number) {
const refer = makeTask(this.logger, {'sip:refer': {
const refer = makeTask(this.logger, normalizeJambones(this.logger, [{'sip:refer': {
referTo: number,
referredBy: 'cognigy'
}});
}}])[0]);
return refer;
}
_makeHangupTask(reason) {
const hangup = makeTask(this.logger, normalizeJambones(this.logger, [{hangup: {
headers: {
'X-Reason': reason
}
}}])[0]);
return hangup;
}
/* if we need to interrupt the currently-running say task(s), call this */
_killSayTasks(ep) {
// this will also remove all other upcoming tasks after the say task
@@ -273,6 +283,7 @@ class Cognigy extends Task {
this._enqueueTask(async() => {
this.performAction({cognigyResult: 'hangup Succeeded'});
this.reportedFinalAction = true;
cs.replaceApplication([this._makeReferTask(evt.data.reason)]);
cs.replaceApplication([{hangup: {
headers: {
'X-Reason': evt.data.reason
@@ -286,10 +297,7 @@ class Cognigy extends Task {
this._enqueueTask(async() => {
this.performAction({cognigyResult: 'refer succeeded'});
this.reportedFinalAction = true;
cs.replaceApplication([{'sip:refer': {
referTo: evt.data.number,
referredBy: 'cognigy'
}}]);
cs.replaceApplication([this._makeReferTask(evt.data.number)]);
});
return;
default: