From 6dbbbf8c9ed0a2d8c0a21c83643f40d122ef99ff Mon Sep 17 00:00:00 2001 From: akirilyuk Date: Tue, 1 Feb 2022 16:35:44 +0100 Subject: [PATCH] improve hangup --- lib/tasks/cognigy/index.js | 20 +++++++------------- lib/tasks/cognigy/speech-config.js | 6 +++--- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/tasks/cognigy/index.js b/lib/tasks/cognigy/index.js index 0b709e26..926d075c 100644 --- a/lib/tasks/cognigy/index.js +++ b/lib/tasks/cognigy/index.js @@ -196,15 +196,6 @@ class Cognigy extends Task { return say; } - _makeHangupTask(reason) { - const hangup = makeTask(this.logger, {hangup: { - headers: { - 'X-REASON': reason - } - }}, this); - return hangup; - } - _makeReferTask(number) { const refer = makeTask(this.logger, {'sip:refer': { referTo: number, @@ -279,12 +270,15 @@ class Cognigy extends Task { switch (evt.data.type) { case 'hangup': this._enqueueTask((async() => { - const hangupTask = this._makeHangupTask(evt.data.reason); - await hangupTask.exec(cs, ep, this); this.performAction({cognigyResult: 'hangup Succeeded'}); this.reportedFinalAction = true; - this.notifyTaskDone(); - this.kill(cs); + const hangupTask = this._makeHangupTask(evt.data.reason); + await hangupTask.exec(cs, ep, this); + cs.replaceApplication([{hangup: { + headers: { + 'X-Reason': evt.data.reason + } + }}]); }).bind(this)); return; diff --git a/lib/tasks/cognigy/speech-config.js b/lib/tasks/cognigy/speech-config.js index 12dd4142..ff9fb2bd 100644 --- a/lib/tasks/cognigy/speech-config.js +++ b/lib/tasks/cognigy/speech-config.js @@ -93,12 +93,12 @@ class SpeechConfig extends Emitter { this.turnConfig = {}; const finalConfig = final; - if(sayConfig){ + if (sayConfig) { finalConfig.say = sayConfig; - }else if(playConfig){ + } else if (playConfig) { finalConfig.play = playConfig; } - this.logger.info({finalConfig}, "created gather config"); + this.logger.info({finalConfig}, 'created gather config'); return finalConfig; } }