Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat: allow private chats between users and moderators (#16165)

Avram Tudor4decb41a1ed4
diff --git a/config.js b/config.js
index 2e80e4bb68..72ccb240d4 100644
--- a/config.js
+++ b/config.js
@@ -1360,8 +1360,9 @@ var config = {
// disableKick: true,
// // If set to true the 'Grant moderator' button will be disabled.
// disableGrantModerator: true,
- // // If set to true the 'Send private message' button will be disabled.
- // disablePrivateChat: true,
+ // // If set to 'all' the 'Private chat' button will be disabled for all participants.
+ // // If set to 'allow-moderator-chat' the 'Private chat' button will be available for chats with moderators.
+ // disablePrivateChat: 'all' | 'allow-moderator-chat',
// },
diff --git a/react/features/analytics/handlers/amplitude/deviceIDStorageUtils.js b/react/features/analytics/handlers/amplitude/deviceIDStorageUtils.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index f787d11579..c3f2d28c7e 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -552,7 +552,7 @@ export interface IConfig {
disableDemote?: boolean;
disableGrantModerator?: boolean;
disableKick?: boolean;
- disablePrivateChat?: boolean;
+ disablePrivateChat?: 'all' | 'allow-moderator-chat';
disabled?: boolean;
};
replaceParticipant?: string;
diff --git a/react/features/base/participants/functions.ts b/react/features/base/participants/functions.ts
index 25bb452ad2..28c7ad175b 100644
--- a/react/features/base/participants/functions.ts
+++ b/react/features/base/participants/functions.ts
@@ -823,3 +823,25 @@ export const setShareDialogVisiblity = (addPeopleFeatureEnabled: boolean, dispat
dispatch(toggleShareDialog(true));
}
};
+
+/**
+ * Checks if private chat is enabled for the given participant.
+ *
+ * @param {IParticipant|undefined} participant - The participant to check.
+ * @param {IReduxState} state - The Redux state.
+ * @returns {boolean} - True if private chat is enabled, false otherwise.
+ */
+export function isPrivateChatEnabled(participant: IParticipant | undefined, state: IReduxState) {
+ const { remoteVideoMenu = {} } = state['features/base/config'];
+ const { disablePrivateChat } = remoteVideoMenu;
+
+ if (participant?.local || state['features/visitors'].iAmVisitor || disablePrivateChat === 'all') {
+ return false;
+ }
+
+ if (disablePrivateChat === 'allow-moderator-chat') {
+ return isLocalParticipantModerator(state) || isParticipantModerator(participant);
+ }
+
+ return !disablePrivateChat;
+}
diff --git a/react/features/chat/components/web/ChatMessage.tsx b/react/features/chat/components/web/ChatMessage.tsx
index 140c1ad61b..0bd7417153 100644
--- a/react/features/chat/components/web/ChatMessage.tsx
+++ b/react/features/chat/components/web/ChatMessage.tsx
@@ -5,7 +5,7 @@ import { makeStyles } from 'tss-react/mui';
import { IReduxState } from '../../../app/types';
import { translate } from '../../../base/i18n/functions';
-import { getParticipantDisplayName } from '../../../base/participants/functions';
+import { getParticipantById, getParticipantDisplayName, isPrivateChatEnabled } from '../../../base/participants/functions';
import Popover from '../../../base/popover/components/Popover.web';
import Message from '../../../base/react/components/web/Message';
import { withPixelLineHeight } from '../../../base/styles/functions.web';
@@ -412,10 +412,12 @@ const ChatMessage = ({
*/
function _mapStateToProps(state: IReduxState, { message }: IProps) {
const { knocking } = state['features/lobby'];
- const localParticipantId = state['features/base/participants'].local?.id;
+
+ const participant = getParticipantById(state, message.participantId);
+ const enablePrivateChat = isPrivateChatEnabled(participant, state);
return {
- shouldDisplayChatMessageMenu: message.participantId !== localParticipantId,
+ shouldDisplayChatMessageMenu: enablePrivateChat,
knocking,
state
};
diff --git a/react/features/video-menu/components/native/RemoteVideoMenu.tsx b/react/features/video-menu/components/native/RemoteVideoMenu.tsx
index 330e9381b2..c51d25343f 100644
--- a/react/features/video-menu/components/native/RemoteVideoMenu.tsx
+++ b/react/features/video-menu/components/native/RemoteVideoMenu.tsx
@@ -17,7 +17,8 @@ import {
getParticipantById,
getParticipantDisplayName,
hasRaisedHand,
- isLocalParticipantModerator
+ isLocalParticipantModerator,
+ isPrivateChatEnabled
} from '../../../base/participants/functions';
import { getBreakoutRooms, getCurrentRoomId, isInBreakoutRoom } from '../../../breakout-rooms/functions';
import { IRoom } from '../../../breakout-rooms/types';
@@ -61,14 +62,14 @@ interface IProps {
_disableKick: boolean;
/**
- * Whether or not to display the send private message button.
+ * Whether or not to display the remote mute buttons.
*/
- _disablePrivateChat: boolean;
+ _disableRemoteMute: boolean;
/**
- * Whether or not to display the remote mute buttons.
+ * Whether or not to display the send private message button.
*/
- _disableRemoteMute: boolean;
+ _enablePrivateChat: boolean;
/**
* Whether or not the current room is a breakout room.
@@ -150,9 +151,9 @@ class RemoteVideoMenu extends PureComponent<IProps> {
override render() {
const {
_disableKick,
- _disablePrivateChat,
_disableRemoteMute,
_disableGrantModerator,
+ _enablePrivateChat,
_isBreakoutRoom,
_isParticipantAvailable,
_isParticipantSilent,
@@ -191,7 +192,7 @@ class RemoteVideoMenu extends PureComponent<IProps> {
{ !_disableGrantModerator && !_isBreakoutRoom && <GrantModeratorButton { ...buttonProps } /> }
<PinButton { ...buttonProps } />
{ _showDemote && <DemoteToVisitorButton { ...buttonProps } /> }
- { !_disablePrivateChat && <PrivateMessageButton { ...buttonProps } /> }
+ { _enablePrivateChat && <PrivateMessageButton { ...buttonProps } /> }
<ConnectionStatusButton { ...connectionStatusButtonProps } />
{_moderator && _rooms.length > 1 && <>
{/* @ts-ignore */}
@@ -258,7 +259,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
const { participantId } = ownProps;
const { remoteVideoMenu = {}, disableRemoteMute } = state['features/base/config'];
const participant = getParticipantById(state, participantId);
- const { disableKick, disablePrivateChat } = remoteVideoMenu;
+ const { disableKick } = remoteVideoMenu;
const _rooms = Object.values(getBreakoutRooms(state));
const _currentRoomId = getCurrentRoomId(state);
const shouldDisableKick = disableKick || !kickOutEnabled;
@@ -271,7 +272,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
_currentRoomId,
_disableKick: Boolean(shouldDisableKick),
_disableRemoteMute: Boolean(disableRemoteMute),
- _disablePrivateChat: Boolean(disablePrivateChat) || _iAmVisitor,
+ _enablePrivateChat: isPrivateChatEnabled(participant, state),
_isBreakoutRoom,
_isParticipantAvailable: Boolean(participant),
_isParticipantSilent: Boolean(participant?.isSilent),
diff --git a/react/features/video-menu/components/web/ParticipantContextMenu.tsx b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
index 3eabde6845..4578dd9c52 100644
--- a/react/features/video-menu/components/web/ParticipantContextMenu.tsx
+++ b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
@@ -9,7 +9,7 @@ import Avatar from '../../../base/avatar/components/Avatar';
import { isIosMobileBrowser, isMobileBrowser } from '../../../base/environment/utils';
import { MEDIA_TYPE } from '../../../base/media/constants';
import { PARTICIPANT_ROLE } from '../../../base/participants/constants';
-import { getLocalParticipant, hasRaisedHand } from '../../../base/participants/functions';
+import { getLocalParticipant, hasRaisedHand, isPrivateChatEnabled } from '../../../base/participants/functions';
import { IParticipant } from '../../../base/participants/types';
import { isParticipantAudioMuted, isParticipantVideoMuted } from '../../../base/tracks/functions.any';
import ContextMenu from '../../../base/ui/components/web/ContextMenu';
@@ -24,7 +24,6 @@ import { getQuickActionButtonType, isForceMuted } from '../../../participants-pa
import { requestRemoteControl, stopController } from '../../../remote-control/actions';
import { getParticipantMenuButtonsWithNotifyClick, showOverflowDrawer } from '../../../toolbox/functions.web';
import { NOTIFY_CLICK_MODE } from '../../../toolbox/types';
-import { iAmVisitor } from '../../../visitors/functions';
import { PARTICIPANT_MENU_BUTTONS as BUTTONS } from '../../constants';
import AskToUnmuteButton from './AskToUnmuteButton';
@@ -141,9 +140,8 @@ const ParticipantContextMenu = ({
const _overflowDrawer: boolean = useSelector(showOverflowDrawer);
const { remoteVideoMenu = {}, disableRemoteMute, startSilent, customParticipantMenuButtons }
= useSelector((state: IReduxState) => state['features/base/config']);
- const visitorsMode = useSelector((state: IReduxState) => iAmVisitor(state));
const visitorsSupported = useSelector((state: IReduxState) => state['features/visitors'].supported);
- const { disableDemote, disableKick, disableGrantModerator, disablePrivateChat } = remoteVideoMenu;
+ const { disableDemote, disableKick, disableGrantModerator } = remoteVideoMenu;
const { participantsVolume } = useSelector((state: IReduxState) => state['features/filmstrip']);
const _volume = (participant?.local ?? true ? undefined
: participant?.id ? participantsVolume[participant?.id] : undefined) ?? 1;
@@ -153,6 +151,7 @@ const ParticipantContextMenu = ({
const stageFilmstrip = useSelector(isStageFilmstripAvailable);
const shouldDisplayVerification = useSelector((state: IReduxState) => displayVerification(state, participant?.id));
const buttonsWithNotifyClick = useSelector(getParticipantMenuButtonsWithNotifyClick);
+ const enablePrivateChat = useSelector((state: IReduxState) => isPrivateChatEnabled(participant, state));
const _currentRoomId = useSelector(getCurrentRoomId);
const _rooms: IRoom[] = Object.values(useSelector(getBreakoutRooms));
@@ -268,7 +267,7 @@ const ParticipantContextMenu = ({
buttons2.push(<TogglePinToStageButton { ...getButtonProps(BUTTONS.PIN_TO_STAGE) } />);
}
- if (!disablePrivateChat && !visitorsMode) {
+ if (enablePrivateChat) {
buttons2.push(<PrivateMessageMenuButton { ...getButtonProps(BUTTONS.PRIVATE_MESSAGE) } />);
}