UNPKG

@onereach/step-voice

Version:
47 lines (46 loc) 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const lodash_1 = tslib_1.__importDefault(require("lodash")); const voice_1 = tslib_1.__importDefault(require("./voice")); class ConferenceDial extends voice_1.default { async runStep() { const call = await this.fetchData(); this.triggers .local(`in/voice/${call.id}`, async (event) => { switch (event.params.type) { case 'hangup': await this.handleHangup(call); return await this.waitConvEnd(); case 'conference-start': if (this.data.stayInConference) { return this.exitFlow(); } else { return this.exitStep('next', lodash_1.default.omit(event.params, ['type'])); } case 'conference-end': return this.data.stayInConference ? this.exitStep('next') : this.exitFlow(); case 'error': return this.throwError(event.params.error); default: return this.exitFlow(); } }); this.triggers.otherwise(async () => { const { sourceConf, botNumber, headers, hearOnly } = this.data; const command = { name: 'conference.joinBot', params: { room: sourceConf, botNumber, headers, hearOnly, stayInConference: this.data.stayInConference } }; await this.sendCommands(call, [command]); }); } } exports.default = ConferenceDial;