UNPKG

@onereach/step-voice

Version:
68 lines (67 loc) 2.76 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 JoinConference extends voice_1.default { async runStep() { const call = await this.fetchData(); const { conferenceName, stayInConference, volumeIn, volumeOut, mute, energyLevel } = this.data; 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': call.conference = { room: event.params.room, user: event.params.user }; await this.transcript(call, { conferenceId: conferenceName, reportingSettingsKey: 'transcript', action: 'Conference Join', actionFromBot: true }); if (stayInConference) { return this.exitFlow(); } else { return this.exitStep('next', lodash_1.default.omit(event.params, ['type'])); } case 'conference-end': call.conference = undefined; await this.transcript(call, { conferenceId: conferenceName, reportingSettingsKey: 'transcript', action: 'Conference End', actionFromBot: true }); return stayInConference ? this.exitStep('next') : this.exitFlow(); case 'error': return this.throwError(event.params.error); default: return this.exitFlow(); } }); this.triggers.otherwise(async () => { const command = { name: 'conference.start', params: { room: conferenceName, flags: [ call.vv >= 3 ? 'mandatory_member_endconf' : 'endconf', ...mute ? ['mute'] : [] ], stayInConference, volumeIn, volumeOut, energyLevel } }; await this.sendCommands(call, [command]); return this.exitFlow(); }); } } exports.default = JoinConference;