improve hangup

This commit is contained in:
akirilyuk
2022-02-01 16:35:44 +01:00
parent 4ea9707e4e
commit 6dbbbf8c9e
2 changed files with 10 additions and 16 deletions

View File

@@ -196,15 +196,6 @@ class Cognigy extends Task {
return say; return say;
} }
_makeHangupTask(reason) {
const hangup = makeTask(this.logger, {hangup: {
headers: {
'X-REASON': reason
}
}}, this);
return hangup;
}
_makeReferTask(number) { _makeReferTask(number) {
const refer = makeTask(this.logger, {'sip:refer': { const refer = makeTask(this.logger, {'sip:refer': {
referTo: number, referTo: number,
@@ -279,12 +270,15 @@ class Cognigy extends Task {
switch (evt.data.type) { switch (evt.data.type) {
case 'hangup': case 'hangup':
this._enqueueTask((async() => { this._enqueueTask((async() => {
const hangupTask = this._makeHangupTask(evt.data.reason);
await hangupTask.exec(cs, ep, this);
this.performAction({cognigyResult: 'hangup Succeeded'}); this.performAction({cognigyResult: 'hangup Succeeded'});
this.reportedFinalAction = true; this.reportedFinalAction = true;
this.notifyTaskDone(); const hangupTask = this._makeHangupTask(evt.data.reason);
this.kill(cs); await hangupTask.exec(cs, ep, this);
cs.replaceApplication([{hangup: {
headers: {
'X-Reason': evt.data.reason
}
}}]);
}).bind(this)); }).bind(this));
return; return;

View File

@@ -98,7 +98,7 @@ class SpeechConfig extends Emitter {
} else if (playConfig) { } else if (playConfig) {
finalConfig.play = playConfig; finalConfig.play = playConfig;
} }
this.logger.info({finalConfig}, "created gather config"); this.logger.info({finalConfig}, 'created gather config');
return finalConfig; return finalConfig;
} }
} }