@onereach/step-voice 6.0.11 → 6.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ interface EVENT extends VoiceEvent {
26
26
  tags?: string[];
27
27
  out?: string;
28
28
  background?: boolean;
29
+ zombie?: boolean;
29
30
  }
30
31
  export default class GlobalCommand extends VoiceStep<Partial<INPUT>, OUTPUT, EVENT> {
31
32
  get isGlobal(): boolean;
@@ -70,6 +70,7 @@ class GlobalCommand extends voice_1.default {
70
70
  this.triggers.hook({ name: "waitEnd" /* ACTION.waitEnd */, thread: types_1.MAIN_THREAD_ID, sync: true }, async () => {
71
71
  delete this.waits['@waitEnd']; // TODO is there beter way to unsubscribe?
72
72
  if (!call.ended) {
73
+ this.state.passive = true;
73
74
  await this.sendCommands(call, [{ name: 'grammar', params: {} }]);
74
75
  }
75
76
  if (this.thread.background)
@@ -77,10 +78,8 @@ class GlobalCommand extends voice_1.default {
77
78
  });
78
79
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
79
80
  switch (event.params.type) {
80
- case 'hangup': {
81
- await this.hangup(call);
82
- return;
83
- }
81
+ case 'hangup':
82
+ return await this.hangup(call);
84
83
  case 'avm-detected':
85
84
  return await this.exitThread(event, 'AMD', 'AMD');
86
85
  case 'digit':
@@ -147,9 +146,20 @@ class GlobalCommand extends voice_1.default {
147
146
  });
148
147
  }
149
148
  async hangup(call) {
149
+ if (this.event.params.zombie) {
150
+ if (this.state.passive) {
151
+ this.log.debug('ignore zombie hangup waiting for full hangup');
152
+ return this.exitFlow();
153
+ }
154
+ this.log.debug('this gc was ignored because call is aleady hang up');
155
+ return this.end();
156
+ }
150
157
  await this.handleHangup(call);
151
158
  const isHangedUpByBot = call.sessionEndedBy === 'Bot';
152
- const hangUpType = isHangedUpByBot ? 'bot hang up' : 'user hang up';
159
+ let hangUpType = isHangedUpByBot ? 'bot hang up' : 'user hang up';
160
+ if (this.event.params.error != null) {
161
+ hangUpType = 'unexpected hang up';
162
+ }
153
163
  let processHangUp = this.data.processHangUp;
154
164
  // process call recording in hangup event
155
165
  if (call.recordCall && this.event.params.callRecording != null) {
package/dst/voice.js CHANGED
@@ -364,7 +364,6 @@ class VoiceStep extends step_1.default {
364
364
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
365
365
  delete this.waits[this.event.name];
366
366
  }
367
- this.log.debug('>>> sleepUntilHangup', { name: this.event.name, waits: this.waits });
368
367
  }
369
368
  }
370
369
  exports.default = VoiceStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "6.0.11",
3
+ "version": "6.0.13",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",