Skip to content

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

fix(whiteboard): validate collaboration data before opening and notify on failure (#17421)

Mihaela Dumitru1814e37e2aa0
diff --git a/modules/API/API.js b/modules/API/API.js
index 5b75033d0b..7f1981836f 100755
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -964,8 +964,8 @@ function initCommands() {
logger.error(' End Conference not supported');
}
},
- 'toggle-whiteboard': () => {
- APP.store.dispatch(toggleWhiteboard());
+ 'toggle-whiteboard': open => {
+ APP.store.dispatch(toggleWhiteboard(open));
},
'set-virtual-background': (enabled, backgroundImage) => {
const tracks = APP.store.getState()['features/base/tracks'];
diff --git a/react/features/whiteboard/actions.any.ts b/react/features/whiteboard/actions.any.ts
index 2e13fa6a70..3b6e16af9d 100644
--- a/react/features/whiteboard/actions.any.ts
+++ b/react/features/whiteboard/actions.any.ts
@@ -46,15 +46,18 @@ export const resetWhiteboard = (): IWhiteboardAction => {
* Sets the whiteboard visibility status.
*
* @param {boolean} isOpen - The whiteboard visibility flag.
+ * @param {boolean} userInitiated - Whether the action was triggered by a user interaction.
* @returns {{
* type: SET_WHITEBOARD_OPEN,
- * isOpen
+ * isOpen,
+ * userInitiated
* }}
*/
-export const setWhiteboardOpen = (isOpen: boolean): IWhiteboardAction => {
+export const setWhiteboardOpen = (isOpen: boolean, userInitiated?: boolean): IWhiteboardAction => {
return {
type: SET_WHITEBOARD_OPEN,
- isOpen
+ isOpen,
+ userInitiated
};
};
diff --git a/react/features/whiteboard/actions.web.ts b/react/features/whiteboard/actions.web.ts
index f1e8c326e5..4c31aa86f1 100644
--- a/react/features/whiteboard/actions.web.ts
+++ b/react/features/whiteboard/actions.web.ts
@@ -11,21 +11,27 @@ export * from './actions.any';
/**
* API to toggle the whiteboard.
*
+ * @param {boolean} [open] - If provided, explicitly sets the whiteboard open state
+ * instead of toggling based on visibility.
* @returns {Function}
*/
-export function toggleWhiteboard() {
+export function toggleWhiteboard(open?: boolean) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const state = getState();
const isAllowed = isWhiteboardAllowed(state);
const isOpen = isWhiteboardOpen(state);
if (isAllowed) {
- if (isOpen && !isWhiteboardVisible(state)) {
- dispatch(setWhiteboardOpen(true));
+ if (typeof open === 'boolean') {
+ if (open !== isOpen) {
+ dispatch(setWhiteboardOpen(open, true));
+ }
+ } else if (isOpen && !isWhiteboardVisible(state)) {
+ dispatch(setWhiteboardOpen(true, true));
} else if (isOpen && isWhiteboardVisible(state)) {
- dispatch(setWhiteboardOpen(false));
+ dispatch(setWhiteboardOpen(false, true));
} else if (!isOpen) {
- dispatch(setWhiteboardOpen(true));
+ dispatch(setWhiteboardOpen(true, true));
}
} else if (typeof APP !== 'undefined') {
APP.API.notifyWhiteboardStatusChanged(WhiteboardStatus.FORBIDDEN);
diff --git a/react/features/whiteboard/components/web/WhiteboardButton.tsx b/react/features/whiteboard/components/web/WhiteboardButton.tsx
index a522595427..2ff9cb6c14 100644
--- a/react/features/whiteboard/components/web/WhiteboardButton.tsx
+++ b/react/features/whiteboard/components/web/WhiteboardButton.tsx
@@ -5,7 +5,7 @@ import { translate } from '../../../base/i18n/functions';
import { IconWhiteboard, IconWhiteboardHide } from '../../../base/icons/svg';
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
-import { setWhiteboardOpen } from '../../actions.any';
+import { toggleWhiteboard } from '../../actions.web';
import { isWhiteboardButtonVisible, isWhiteboardVisible } from '../../functions';
interface IProps extends AbstractButtonProps {
@@ -36,9 +36,9 @@ class WhiteboardButton extends AbstractButton<IProps> {
* @returns {void}
*/
override _handleClick() {
- const { dispatch, _toggled } = this.props;
+ const { dispatch } = this.props;
- dispatch(setWhiteboardOpen(!_toggled));
+ dispatch(toggleWhiteboard());
dispatch(setOverflowMenuVisible(false));
}
diff --git a/react/features/whiteboard/middleware.web.ts b/react/features/whiteboard/middleware.web.ts
index 44c44a5e46..baab11d9cd 100644
--- a/react/features/whiteboard/middleware.web.ts
+++ b/react/features/whiteboard/middleware.web.ts
@@ -10,6 +10,8 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { getCurrentRoomId } from '../breakout-rooms/functions';
import { addStageParticipant } from '../filmstrip/actions.web';
import { isStageFilmstripAvailable } from '../filmstrip/functions.web';
+import { showErrorNotification } from '../notifications/actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { RESET_WHITEBOARD, SET_WHITEBOARD_OPEN } from './actionTypes';
import {
@@ -22,10 +24,12 @@ import { WHITEBOARD_ID, WHITEBOARD_PARTICIPANT_NAME } from './constants';
import {
generateCollabServerUrl,
getCollabDetails,
+ getCollabServerUrl,
isWhiteboardPresent,
shouldEnforceUserLimit,
shouldNotifyUserLimit
} from './functions';
+import logger from './logger';
import { WhiteboardStatus } from './types';
import './middleware.any';
@@ -66,6 +70,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
switch (action.type) {
case SET_WHITEBOARD_OPEN: {
const existingCollabDetails = getCollabDetails(state);
+ const collabServerUrl = getCollabServerUrl(state);
const enforceUserLimit = shouldEnforceUserLimit(state);
const notifyUserLimit = shouldNotifyUserLimit(state);
const iAmRecorder = Boolean(state['features/base/config'].iAmRecorder);
@@ -79,12 +84,44 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
}
if (!existingCollabDetails) {
- setNewWhiteboardOpen(store);
+ if (action.isOpen) {
+ if (!generateCollabServerUrl(state)) {
+ logger.error('Whiteboard open failed, collabServerBaseUrl not configured');
+
+ if (action.userInitiated) {
+ dispatch(showErrorNotification({
+ titleKey: 'info.noWhiteboard'
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
+ }
+
+ return;
+ }
+ setNewWhiteboardOpen(store);
+
+ return;
+ }
return next(action);
}
if (action.isOpen) {
+ if (!existingCollabDetails.roomId || !existingCollabDetails.roomKey || !collabServerUrl) {
+ const missing = [
+ !existingCollabDetails.roomId && 'roomId',
+ !existingCollabDetails.roomKey && 'roomKey',
+ !collabServerUrl && 'collabServerUrl'
+ ].filter(Boolean).join(', ');
+
+ logger.error(`Whiteboard open failed, missing collaboration data: ${missing}`);
+
+ if (action.userInitiated) {
+ dispatch(showErrorNotification({
+ titleKey: 'info.noWhiteboard'
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
+ }
+
+ return;
+ }
if (enforceUserLimit) {
dispatch(restrictWhiteboard());
@@ -155,8 +192,8 @@ async function setNewWhiteboardOpen(store: IStore) {
collabServerUrl
};
- focusWhiteboard(store);
dispatch(setupWhiteboard(collabData));
conference?.getMetadataHandler().setMetadata(WHITEBOARD_ID, collabData);
raiseWhiteboardNotification(WhiteboardStatus.INSTANTIATED);
}
+
diff --git a/react/features/whiteboard/reducer.ts b/react/features/whiteboard/reducer.ts
index 0a83e5f57a..a3557a03f8 100644
--- a/react/features/whiteboard/reducer.ts
+++ b/react/features/whiteboard/reducer.ts
@@ -20,6 +20,7 @@ export interface IWhiteboardState {
* @type {boolean}
*/
isOpen: boolean;
+
}
const DEFAULT_STATE: IWhiteboardState = {
@@ -44,6 +45,11 @@ export interface IWhiteboardAction extends Partial<IWhiteboardState> {
* The action type.
*/
type: string;
+
+ /**
+ * Whether the action was triggered by a user interaction.
+ */
+ userInitiated?: boolean;
}
ReducerRegistry.register(