37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
|
import Users from '/imports/api/users';
|
|
import VoiceUsers from '/imports/api/voice-users';
|
|
|
|
export default function muteToggle(uId) {
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
const EVENT_NAME = 'MuteUserCmdMsg';
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
const userToMute = uId || requesterUserId;
|
|
|
|
const requester = Users.findOne({
|
|
meetingId,
|
|
userId: requesterUserId,
|
|
});
|
|
|
|
const voiceUser = VoiceUsers.findOne({
|
|
intId: userToMute,
|
|
});
|
|
|
|
if (!requester || !voiceUser) return;
|
|
|
|
const { listenOnly, muted } = voiceUser;
|
|
if (listenOnly) return;
|
|
|
|
const payload = {
|
|
userId: userToMute,
|
|
mutedBy: requesterUserId,
|
|
mute: !muted,
|
|
};
|
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
}
|