mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
normalize things
This commit is contained in:
@@ -4,6 +4,7 @@ const makeTask = require('../make_task');
|
|||||||
const { SocketClient } = require('@cognigy/socket-client');
|
const { SocketClient } = require('@cognigy/socket-client');
|
||||||
const SpeechConfig = require('./speech-config');
|
const SpeechConfig = require('./speech-config');
|
||||||
const queue = require('queue');
|
const queue = require('queue');
|
||||||
|
const normalizeJambones = require('../utils/normalize-jambones');
|
||||||
|
|
||||||
const parseGallery = (obj = {}) => {
|
const parseGallery = (obj = {}) => {
|
||||||
const {_default} = obj;
|
const {_default} = obj;
|
||||||
@@ -199,13 +200,22 @@ class Cognigy extends Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_makeReferTask(number) {
|
_makeReferTask(number) {
|
||||||
const refer = makeTask(this.logger, {'sip:refer': {
|
const refer = makeTask(this.logger, normalizeJambones(this.logger, [{'sip:refer': {
|
||||||
referTo: number,
|
referTo: number,
|
||||||
referredBy: 'cognigy'
|
referredBy: 'cognigy'
|
||||||
}});
|
}}])[0]);
|
||||||
return refer;
|
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 */
|
/* if we need to interrupt the currently-running say task(s), call this */
|
||||||
_killSayTasks(ep) {
|
_killSayTasks(ep) {
|
||||||
// this will also remove all other upcoming tasks after the say task
|
// this will also remove all other upcoming tasks after the say task
|
||||||
@@ -273,6 +283,7 @@ class Cognigy extends Task {
|
|||||||
this._enqueueTask(async() => {
|
this._enqueueTask(async() => {
|
||||||
this.performAction({cognigyResult: 'hangup Succeeded'});
|
this.performAction({cognigyResult: 'hangup Succeeded'});
|
||||||
this.reportedFinalAction = true;
|
this.reportedFinalAction = true;
|
||||||
|
cs.replaceApplication([this._makeReferTask(evt.data.reason)]);
|
||||||
cs.replaceApplication([{hangup: {
|
cs.replaceApplication([{hangup: {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Reason': evt.data.reason
|
'X-Reason': evt.data.reason
|
||||||
@@ -286,10 +297,7 @@ class Cognigy extends Task {
|
|||||||
this._enqueueTask(async() => {
|
this._enqueueTask(async() => {
|
||||||
this.performAction({cognigyResult: 'refer succeeded'});
|
this.performAction({cognigyResult: 'refer succeeded'});
|
||||||
this.reportedFinalAction = true;
|
this.reportedFinalAction = true;
|
||||||
cs.replaceApplication([{'sip:refer': {
|
cs.replaceApplication([this._makeReferTask(evt.data.number)]);
|
||||||
referTo: evt.data.number,
|
|
||||||
referredBy: 'cognigy'
|
|
||||||
}}]);
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user