Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(audio): moderators not able to mute users #20212

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ interface MuteToggleProps {
muted: boolean;
disabled: boolean;
isAudioLocked: boolean;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId?: string | null, muted?: boolean | null) => void) => void;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId: string, muted: boolean) => void) => void;
away: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface MuteToggleProps {
muted: boolean;
disabled: boolean;
isAudioLocked: boolean;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId?: string | null, muted?: boolean | null) => void) => void;
toggleMuteMicrophone: (muted: boolean, toggleVoice: (userId: string, muted: boolean) => void) => void;
away: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Storage from '/imports/ui/services/storage/session';
import logger from '/imports/startup/client/logger';
import AudioManager from '/imports/ui/services/audio-manager';
import VideoService from '/imports/ui/components/video-provider/video-provider-graphql/service';
import Auth from '/imports/ui/services/auth';

const MUTED_KEY = 'muted';
// @ts-ignore - temporary, while meteor exists in the project
Expand Down Expand Up @@ -42,7 +43,7 @@ export const handleLeaveAudio = (meetingIsBreakout: boolean) => {

export const toggleMuteMicrophone = (
muted: boolean,
toggleVoice: (userId?: string | null, muted?: boolean | null) => void,
toggleVoice: (userId: string, muted: boolean) => void,
) => {
Storage.setItem(MUTED_KEY, !muted);

Expand All @@ -54,7 +55,7 @@ export const toggleMuteMicrophone = (
},
'microphone unmuted by user',
);
toggleVoice();
toggleVoice(Auth.userID!, false);
} else {
logger.info(
{
Expand All @@ -63,7 +64,7 @@ export const toggleMuteMicrophone = (
},
'microphone muted by user',
);
toggleVoice();
toggleVoice(Auth.userID!, true);
}
};

Expand Down Expand Up @@ -98,7 +99,7 @@ export const setSpeakerLevel = (level: number) => {
export const muteAway = (
muted: boolean,
away: boolean,
voiceToggle: (userId?: string | null, muted?: boolean | null) => void,
voiceToggle: (userId: string, muted: boolean) => void,
) => {
const prevAwayMuted = Storage.getItem('prevAwayMuted') || false;
const prevSpeakerLevelValue = Storage.getItem('prevSpeakerLevel') || 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback } from 'react';
import { useMutation } from '@apollo/client';
import Auth from '/imports/ui/services/auth';
import { USER_SET_MUTED } from '../mutations';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';

Expand All @@ -12,16 +11,8 @@ const useToggleVoice = () => {
},
}));

const toggleVoice = async (userId?: string | null, muted?: boolean | null) => {
let shouldMute = muted;
const userToMute = userId ?? Auth.userID;

if (muted === undefined || muted === null) {
const muted = currentUserData?.voice?.muted;
shouldMute = !muted;
}

userSetMuted({ variables: { muted: shouldMute, userId: userToMute } });
const toggleVoice = async (userId: string, muted: boolean) => {
userSetMuted({ variables: { muted, userId } });
};

return useCallback(toggleVoice, [currentUserData?.voice?.muted]);
Expand Down
8 changes: 4 additions & 4 deletions bigbluebutton-html5/imports/ui/components/audio/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const recoverMicState = (toggleVoice) => {
logger.debug({
logCode: 'audio_recover_mic_state',
}, `Audio recover previous mic state: muted = ${muted}`);
toggleVoice(null, muted);
toggleVoice(Auth.userID, muted);
};

const audioEventHandler = (toggleVoice) => (event) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ const muteMicrophone = (toggleVoice) => {
extraInfo: { logType: 'user_action' },
}, 'User wants to leave conference. Microphone muted');
AudioManager.setSenderTrackEnabled(false);
toggleVoice();
toggleVoice(Auth.userID, true);
}
};

Expand All @@ -105,13 +105,13 @@ const toggleMuteMicrophone = throttle((toggleVoice) => {
logCode: 'audiomanager_unmute_audio',
extraInfo: { logType: 'user_action' },
}, 'microphone unmuted by user');
toggleVoice();
toggleVoice(Auth.userID, false);
} else {
logger.info({
logCode: 'audiomanager_mute_audio',
extraInfo: { logType: 'user_action' },
}, 'microphone muted by user');
toggleVoice();
toggleVoice(Auth.userID, true);
}
}, TOGGLE_MUTE_THROTTLE_TIME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface TalkingIndicatorProps {
isBreakout: boolean;
moreThanMaxIndicators: boolean;
isModerator: boolean;
toggleVoice: (userId?: string | null, muted?: boolean | null) => void;
toggleVoice: (userId: string, muted: boolean) => void;
}

const TalkingIndicator: React.FC<TalkingIndicatorProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export const muteUser = debounce(
muted: boolean | undefined,
isBreakout: boolean,
isModerator: boolean,
toggleVoice: (userId?: string | null, muted?: string | null) => void,
toggleVoice: (userId: string, muted: boolean) => void,
) => {
if (!isModerator || isBreakout || muted) return null;
toggleVoice(id);
toggleVoice(id, true);
return null;
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ const UserActions: React.FC<UserActionsProps> = ({
key: 'mute',
label: intl.formatMessage(messages.MuteUserAudioLabel),
onClick: () => {
toggleVoice(user.userId, voiceToggle);
toggleVoice(user.userId, true, voiceToggle);
setOpenUserAction(null);
},
icon: 'mute',
Expand All @@ -421,7 +421,7 @@ const UserActions: React.FC<UserActionsProps> = ({
key: 'unmute',
label: intl.formatMessage(messages.UnmuteUserAudioLabel),
onClick: () => {
toggleVoice(user.userId, voiceToggle);
toggleVoice(user.userId, false, voiceToggle);
setOpenUserAction(null);
},
icon: 'unmute',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ export const isVideoPinEnabledForCurrentUser = (
// so this code is duplicated from the old userlist service
// session for chats the current user started

export const toggleVoice = (userId: string, voiceToggle: (userId?: string | null, muted?: boolean | null) => void) => {
export const toggleVoice = (userId: string, muted: boolean, voiceToggle: (userId: string, muted: boolean) => void) => {
if (userId === Auth.userID) {
AudioService.toggleMuteMicrophone(voiceToggle);
} else {
voiceToggle(userId);
voiceToggle(userId, muted);
logger.info({
logCode: 'usermenu_option_mute_toggle_audio',
extraInfo: { logType: 'moderator_action', userId },
Expand Down
Loading