bigbluebutton-Github/bigbluebutton-html5/imports/api/voice-users/server/methods/muteAllExceptPresenterToggle.js
2018-10-11 14:27:56 -07:00

32 lines
947 B
JavaScript
Executable File

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import VoiceUsers from '/imports/api/voice-users';
import Meetings from '/imports/api/meetings';
export default function muteAllExceptPresenterToggle(credentials, userId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'MuteAllExceptPresentersCmdMsg';
const { meetingId, requesterUserId } = credentials;
check(meetingId, String);
check(requesterUserId, String);
const meeting = Meetings.findOne({ meetingId });
const voiceUser = VoiceUsers.findOne({
intId: userId,
});
const { muted } = voiceUser;
const payload = {
mutedBy: requesterUserId,
mute: meeting.voiceProp.muteOnStart ? muted : !muted,
};
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
}