bigbluebutton-Github/bigbluebutton-html5/imports/api/voice-users/server/methods/muteAllExceptPresenterToggle.js

32 lines
947 B
JavaScript
Raw Normal View History

2018-09-29 05:32:52 +08:00
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);
}