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

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-05 04:05:18 +08:00
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import Users from '/imports/api/users';
import VoiceUsers from '/imports/api/voice-users';
2017-08-05 04:05:18 +08:00
export default function muteToggle(credentials, userId) {
const REDIS_CONFIG = Meteor.settings.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'MuteUserCmdMsg';
const APP_CONFIG = Meteor.settings.public.app;
const ALLOW_MODERATOR_TO_UNMUTE_AUDIO = APP_CONFIG.allowModeratorToUnmuteAudio;
2017-08-05 04:05:18 +08:00
const { meetingId, requesterUserId } = credentials;
check(meetingId, String);
check(requesterUserId, String);
const payload = {
userId,
mutedBy: requesterUserId,
};
const { role: requesterRole } = Users.findOne({
meetingId,
userId: requesterUserId,
});
const { muted: isUserMuted } = VoiceUsers.findOne({
intId: userId,
});
if (requesterUserId !== userId && requesterRole === 'MODERATOR' && !ALLOW_MODERATOR_TO_UNMUTE_AUDIO && isUserMuted) return;
2017-09-12 23:52:02 +08:00
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
2017-09-08 00:47:20 +08:00
}