Skip to content

Commit

Permalink
Merge pull request bigbluebutton#21564 from gustavotrott/chat-validat…
Browse files Browse the repository at this point in the history
…e-bkroom

fix: Prevent moderators from deleting others' chat messages in Breakout Rooms
  • Loading branch information
gustavotrott authored Oct 30, 2024
2 parents 981e932 + 0f33c8e commit 0dcb7b2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ trait DeleteGroupChatMessageReqMsgHdlr extends HandlerHelpers {
val userIsOwner = gcMessage.sender.id == user.intId

if ((chatIsPrivate && userIsAParticipant) || !chatIsPrivate) {
if (userIsOwner || userIsModerator) {
if (userIsOwner ||
(userIsModerator && !liveMeeting.props.meetingProp.isBreakout) //not allowed in breakoutRooms as everyone is moderator
) {
val updatedGroupChat = GroupChatApp.deleteGroupChatMessage(liveMeeting.props.meetingProp.intId, groupChat, state.groupChats, gcMessage, user.intId)

val event = buildGroupChatMessageDeletedEvtMsg(liveMeeting.props.meetingProp.intId, msg.header.userId, msg.body.chatId, gcMessage.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ const ChatMessageList: React.FC<ChatListProps> = ({
} = useStickyScroll(currentMessageListContainer, currentMessageListContainer, 'ne');
const { data: meeting } = useMeeting((m) => ({
lockSettings: m?.lockSettings,
isBreakout: m?.isBreakout,
}));
const { data: currentUser } = useCurrentUser((c) => ({
isModerator: c?.isModerator,
Expand Down Expand Up @@ -468,6 +469,7 @@ const ChatMessageList: React.FC<ChatListProps> = ({
currentUserId={currentUser?.userId ?? ''}
currentUserIsLocked={!!currentUser?.locked}
currentUserIsModerator={!!currentUser?.isModerator}
isBreakoutRoom={!!meeting?.isBreakout}
messageToolbarIsEnabled={messageToolbarIsEnabled}
chatDeleteEnabled={CHAT_DELETE_ENABLED}
chatEditEnabled={CHAT_EDIT_ENABLED}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface ChatMessageProps {
currentUserIsLocked: boolean;
currentUserId: string;
currentUserDisablePublicChat: boolean;
isBreakoutRoom: boolean;
isPublicChat: boolean;
hasToolbar: boolean;
chatReplyEnabled: boolean;
Expand Down Expand Up @@ -131,6 +132,7 @@ const ChatMessage = React.forwardRef<ChatMessageRef, ChatMessageProps>(({
currentUserId,
currentUserIsLocked,
currentUserIsModerator,
isBreakoutRoom,
isPublicChat,
hasToolbar,
chatDeleteEnabled,
Expand Down Expand Up @@ -453,6 +455,7 @@ const ChatMessage = React.forwardRef<ChatMessageRef, ChatMessageProps>(({
username={message.user?.name}
own={message.user?.userId === currentUserId}
amIModerator={currentUserIsModerator}
isBreakoutRoom={isBreakoutRoom}
message={message.message}
messageSequence={message.messageSequence}
emphasizedMessage={message.chatEmphasizedText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface ChatMessageToolbarProps {
username: string;
own: boolean;
amIModerator: boolean;
isBreakoutRoom: boolean;
message: string;
messageSequence: number;
emphasizedMessage: boolean;
Expand All @@ -70,7 +71,7 @@ interface ChatMessageToolbarProps {
const ChatMessageToolbar: React.FC<ChatMessageToolbarProps> = (props) => {
const {
messageId, chatId, message, username, onEmojiSelected, deleted,
messageSequence, emphasizedMessage, own, amIModerator, locked,
messageSequence, emphasizedMessage, own, amIModerator, isBreakoutRoom, locked,
onReactionPopoverOpenChange, reactionPopoverIsOpen, hasToolbar, keyboardFocused,
chatDeleteEnabled, chatEditEnabled, chatReactionsEnabled, chatReplyEnabled,
} = props;
Expand Down Expand Up @@ -110,7 +111,7 @@ const ChatMessageToolbar: React.FC<ChatMessageToolbarProps> = (props) => {
const showReplyButton = chatReplyEnabled;
const showReactionsButton = chatReactionsEnabled;
const showEditButton = chatEditEnabled && own;
const showDeleteButton = chatDeleteEnabled && (own || amIModerator);
const showDeleteButton = chatDeleteEnabled && (own || (amIModerator && !isBreakoutRoom));
const showDivider = (showReplyButton || showReactionsButton) && (showEditButton || showDeleteButton);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface ChatListPageCommonProps {
currentUserIsLocked: boolean;
currentUserId: string;
currentUserDisablePublicChat: boolean;
isBreakoutRoom: boolean;
messageToolbarIsEnabled: boolean;
chatReplyEnabled: boolean;
chatDeleteEnabled: boolean;
Expand Down Expand Up @@ -119,6 +120,7 @@ const ChatListPage: React.FC<ChatListPageProps> = ({
currentUserDisablePublicChat,
currentUserIsLocked,
currentUserIsModerator,
isBreakoutRoom,
isPublicChat,
messageToolbarIsEnabled,
chatDeleteEnabled,
Expand Down Expand Up @@ -262,6 +264,7 @@ const ChatListPage: React.FC<ChatListPageProps> = ({
currentUserDisablePublicChat={currentUserDisablePublicChat}
currentUserIsLocked={currentUserIsLocked}
currentUserIsModerator={currentUserIsModerator}
isBreakoutRoom={isBreakoutRoom}
isPublicChat={isPublicChat}
hasToolbar={messageToolbarIsEnabled && !!message.user}
chatDeleteEnabled={chatDeleteEnabled}
Expand Down Expand Up @@ -295,6 +298,7 @@ const ChatListPageContainer: React.FC<ChatListPageContainerProps> = ({
currentUserDisablePublicChat,
currentUserIsLocked,
currentUserIsModerator,
isBreakoutRoom,
messageToolbarIsEnabled,
chatDeleteEnabled,
chatEditEnabled,
Expand Down Expand Up @@ -350,6 +354,7 @@ const ChatListPageContainer: React.FC<ChatListPageContainerProps> = ({
currentUserDisablePublicChat={currentUserDisablePublicChat}
currentUserIsLocked={currentUserIsLocked}
currentUserIsModerator={currentUserIsModerator}
isBreakoutRoom={isBreakoutRoom}
isPublicChat={isPublicChat}
messageToolbarIsEnabled={messageToolbarIsEnabled}
chatDeleteEnabled={chatDeleteEnabled}
Expand Down

0 comments on commit 0dcb7b2

Please sign in to comment.