diff --git a/lib/session/call-session.js b/lib/session/call-session.js index d7820488..f270d626 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -468,6 +468,14 @@ class CallSession extends Emitter { task.doConferenceHold(this, opts); } + async _lccConfMute(callSid, mute) { + const task = this.currentTask; + if (!task || TaskName.Conference !== task.name || !this.isInConference) { + return this.logger.info('CallSession:_lccConfMute - invalid command as call is not in conference'); + } + task.doConferenceMuteNonModerators(this, mute); + } + /** * perform live call control -- whisper to one party or the other on a call * @param {array} opts - array of play or say tasks @@ -540,6 +548,9 @@ class CallSession extends Emitter { else if (opts.conf_hold_status) { await this._lccConfHoldStatus(callSid, opts); } + else if ('mute_conference' in opts) { + await this._lccConfMute(callSid, opts.mute_conference); + } // whisper may be the only thing we are asked to do, or it may that // we are doing a whisper after having muted, paused reccording etc.. diff --git a/lib/tasks/conference.js b/lib/tasks/conference.js index 17f6c9a4..ae023bac 100644 --- a/lib/tasks/conference.js +++ b/lib/tasks/conference.js @@ -379,6 +379,19 @@ class Conference extends Task { this.emitter.emit('join', opts); } + async doConferenceMuteNonModerators(cs, mute) { + assert (cs.isInConference); + + this.logger.info(`Conference:doConferenceMuteNonModerators ${mute ? 'muting' : 'unmuting'} non-moderators`); + this.ep.api(`conference ${this.confName} ${mute ? 'mute' : 'unmute'} non_moderator`) + .catch((err) => this.logger.info({err}, 'Error muting or unmuting non_moderators')); + + if (this.conf_hold_status !== 'hold' && this._playSession) { + this._playSession.kill(); + this._playSession = null; + } + } + async doConferenceHold(cs, opts) { assert (cs.isInConference);