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(whiteboard) add user limit (#13870)

Mihaela Dumitru006e8463cd45
diff --git a/config.js b/config.js
index 4de5cecfaa..d06de8920a 100644
--- a/config.js
+++ b/config.js
@@ -1695,6 +1695,11 @@ var config = {
// // The server used to support whiteboard collaboration.
// // https://github.com/jitsi/excalidraw-backend
// collabServerBaseUrl: 'https://excalidraw-backend.example.com',
+ // // The user access limit to the whiteboard, introduced as a means
+ // // to control the performance.
+ // userLimit: 25,
+ // // The url for more info about the whiteboard and its usage limitations.
+ // limitUrl: 'https://example.com/blog/whiteboard-limits,
// },
// The watchRTC initialize config params as described :
diff --git a/lang/main.json b/lang/main.json
index 7a0b006704..03f46af668 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -482,6 +482,10 @@
"viewUpgradeOptions": "View upgrade options",
"viewUpgradeOptionsContent": "To get unlimited access to premium features like recording, transcriptions, RTMP Streaming & more, you'll need to upgrade your plan.",
"viewUpgradeOptionsTitle": "You discovered a premium feature!",
+ "whiteboardLimitContent": "Sorry, the limit of conccurent whiteboard users has been reached.",
+ "whiteboardLimitReference": "For more information please visit",
+ "whiteboardLimitReferenceUrl": "our website",
+ "whiteboardLimitTitle": "Whiteboard usage restricted",
"yourEntireScreen": "Your entire screen"
},
"documentSharing": {
@@ -804,7 +808,9 @@
"videoUnmuteBlockedDescription": "Camera unmute and desktop sharing operation have been temporarily blocked because of system limits.",
"videoUnmuteBlockedTitle": "Camera unmute and desktop sharing blocked!",
"viewLobby": "View lobby",
- "waitingParticipants": "{{waitingParticipants}} people"
+ "waitingParticipants": "{{waitingParticipants}} people",
+ "whiteboardLimitDescription": "Please save your progress, as the user limit will soon be reached and the whiteboard will close.",
+ "whiteboardLimitTitle": "Whiteboard usage"
},
"participantsPane": {
"actions": {
diff --git a/react/features/analytics/AnalyticsEvents.ts b/react/features/analytics/AnalyticsEvents.ts
index 8ac44a4486..588bc5a050 100644
--- a/react/features/analytics/AnalyticsEvents.ts
+++ b/react/features/analytics/AnalyticsEvents.ts
@@ -934,3 +934,27 @@ export function createGifSentEvent() {
action: 'gif.sent'
};
}
+
+/**
+ * Creates an event which indicates the whiteboard was opened.
+ *
+ * @returns {Object} The event in a format suitable for sending via
+ * sendAnalytics.
+ */
+export function createOpenWhiteboardEvent() {
+ return {
+ action: 'whiteboard.open'
+ };
+}
+
+/**
+ * Creates an event which indicates the whiteboard limit was enforced.
+ *
+ * @returns {Object} The event in a format suitable for sending via
+ * sendAnalytics.
+ */
+export function createRestrictWhiteboardEvent() {
+ return {
+ action: 'whiteboard.restrict'
+ };
+}
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 5f2da0342d..5050fd2ff7 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -157,6 +157,13 @@ export interface INoiseSuppressionConfig {
};
}
+export interface IWhiteboardConfig {
+ collabServerBaseUrl?: string;
+ enabled?: boolean;
+ limitUrl?: string;
+ userLimit?: number;
+}
+
export interface IWatchRTCConfiguration {
allowBrowserLogCollection?: boolean;
collectionInterval?: number;
@@ -630,8 +637,5 @@ export interface IConfig {
customUrl?: string;
disabled?: boolean;
};
- whiteboard?: {
- collabServerBaseUrl?: string;
- enabled?: boolean;
- };
+ whiteboard?: IWhiteboardConfig;
}
diff --git a/react/features/large-video/components/LargeVideo.web.tsx b/react/features/large-video/components/LargeVideo.web.tsx
index a97217d3cf..da26829648 100644
--- a/react/features/large-video/components/LargeVideo.web.tsx
+++ b/react/features/large-video/components/LargeVideo.web.tsx
@@ -17,7 +17,7 @@ import SharedVideo from '../../shared-video/components/web/SharedVideo';
import Captions from '../../subtitles/components/web/Captions';
import { setTileView } from '../../video-layout/actions.web';
import Whiteboard from '../../whiteboard/components/web/Whiteboard';
-import { isWhiteboardEnabled } from '../../whiteboard/functions';
+import { isWhiteboardReady } from '../../whiteboard/functions';
import { setSeeWhatIsBeingShared } from '../actions.web';
import { getLargeVideoParticipant } from '../functions';
@@ -110,9 +110,9 @@ interface IProps {
_visibleFilmstrip: boolean;
/**
- * Whether or not the whiteboard is enabled.
+ * Whether or not the whiteboard is ready to be used.
*/
- _whiteboardEnabled: boolean;
+ _whiteboardReady: boolean;
/**
* The Redux dispatch function.
@@ -193,7 +193,7 @@ class LargeVideo extends Component<IProps> {
_isChatOpen,
_noAutoPlayVideo,
_showDominantSpeakerBadge,
- _whiteboardEnabled
+ _whiteboardReady
} = this.props;
const style = this._getCustomStyles();
const className = `videocontainer${_isChatOpen ? ' shift-right' : ''}`;
@@ -205,7 +205,7 @@ class LargeVideo extends Component<IProps> {
ref = { this._containerRef }
style = { style }>
<SharedVideo />
- {_whiteboardEnabled && <Whiteboard />}
+ {_whiteboardReady && <Whiteboard />}
<div id = 'etherpad' />
<Watermarks />
@@ -377,7 +377,7 @@ function _mapStateToProps(state: IReduxState) {
_verticalFilmstripWidth: verticalFilmstripWidth.current,
_verticalViewMaxWidth: getVerticalViewMaxWidth(state),
_visibleFilmstrip: visible,
- _whiteboardEnabled: isWhiteboardEnabled(state)
+ _whiteboardReady: isWhiteboardReady(state)
};
}
diff --git a/react/features/whiteboard/actions.ts b/react/features/whiteboard/actions.ts
index 21bd7ca0b7..912ab2f526 100644
--- a/react/features/whiteboard/actions.ts
+++ b/react/features/whiteboard/actions.ts
@@ -1,3 +1,9 @@
+import { createRestrictWhiteboardEvent } from '../analytics/AnalyticsEvents';
+import { sendAnalytics } from '../analytics/functions';
+import { IStore } from '../app/types';
+import { showWarningNotification } from '../notifications/actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
+
import {
RESET_WHITEBOARD,
SETUP_WHITEBOARD,
@@ -50,3 +56,27 @@ export const setWhiteboardOpen = (isOpen: boolean): IWhiteboardAction => {
isOpen
};
};
+
+/**
+ * Shows a warning notification about the whiteboard user limit.
+ *
+ * @returns {Function}
+ */
+export const notifyWhiteboardLimit = () => (dispatch: IStore['dispatch']) => {
+ dispatch(showWarningNotification({
+ titleKey: 'notify.whiteboardLimitTitle',
+ descriptionKey: 'notify.whiteboardLimitDescription'
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG));
+};
+
+/**
+ * Restricts the whiteboard usage.
+ *
+ * @param {boolean} shouldCloseWhiteboard - Whether to dismiss the whiteboard participant.
+ * @returns {Function}
+ */
+export const restrictWhiteboard = (shouldCloseWhiteboard = true) => (dispatch: IStore['dispatch']) => {
+ shouldCloseWhiteboard && dispatch(setWhiteboardOpen(false));
+ dispatch(resetWhiteboard());
+ sendAnalytics(createRestrictWhiteboardEvent());
+};
diff --git a/react/features/whiteboard/components/web/WhiteboardLimitDialog.tsx b/react/features/whiteboard/components/web/WhiteboardLimitDialog.tsx
new file mode 100644
index 0000000000..8ca795f6ef
--- /dev/null
+++ b/react/features/whiteboard/components/web/WhiteboardLimitDialog.tsx
@@ -0,0 +1,39 @@
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+import { useSelector } from 'react-redux';
+
+import Dialog from '../../../base/ui/components/web/Dialog';
+import { getWhiteboardConfig } from '../../functions';
+
+/**
+ * Component that renders the whiteboard user limit dialog.
+ *
+ * @returns {JSX.Element}
+ */
+const WhiteboardLimitDialog = () => {
+ const { t } = useTranslation();
+ const { limitUrl } = useSelector(getWhiteboardConfig);
+
+ return (
+ <Dialog
+ cancel = {{ hidden: true }}
+ ok = {{ hidden: true }}
+ titleKey = { t('dialog.whiteboardLimitTitle') }>
+ <span>{t('dialog.whiteboardLimitContent')}</span>
+ {limitUrl && (
+ <span>
+ {` ${t('dialog.whiteboardLimitReference')} `}
+ <a
+ href = { limitUrl }
+ rel = 'noopener noreferrer'
+ target = '_blank'>
+ {t('dialog.whiteboardLimitReferenceUrl')}
+ </a>
+ .
+ </span>
+ )}
+ </Dialog>
+ );
+};
+
+export default WhiteboardLimitDialog;
diff --git a/react/features/whiteboard/constants.ts b/react/features/whiteboard/constants.ts
index 920b105bdc..0202c14418 100644
--- a/react/features/whiteboard/constants.ts
+++ b/react/features/whiteboard/constants.ts
@@ -52,3 +52,13 @@ export const WHITEBOARD_UI_OPTIONS = {
}
}
};
+
+/**
+ * Whiteboard default lower limit.
+ */
+export const MIN_USER_LIMIT = 10;
+
+/**
+ * Whiteboard soft limit diff.
+ */
+export const USER_LIMIT_THRESHOLD = 5;
diff --git a/react/features/whiteboard/functions.ts b/react/features/whiteboard/functions.ts
index a1561b3719..715480b92d 100644
--- a/react/features/whiteboard/functions.ts
+++ b/react/features/whiteboard/functions.ts
@@ -1,17 +1,39 @@
import md5 from 'js-md5';
-import { getPinnedParticipant } from '../../features/base/participants/functions';
+import { getParticipantCount, getPinnedParticipant } from '../../features/base/participants/functions';
import { IReduxState } from '../app/types';
import { getCurrentConference } from '../base/conference/functions';
+import { IWhiteboardConfig } from '../base/config/configType';
import { getRemoteParticipants, isLocalParticipantModerator } from '../base/participants/functions';
import { appendURLParam } from '../base/util/uri';
import { getCurrentRoomId, isInBreakoutRoom } from '../breakout-rooms/functions';
-import { WHITEBOARD_ID } from './constants';
+import { MIN_USER_LIMIT, USER_LIMIT_THRESHOLD, WHITEBOARD_ID } from './constants';
import { IWhiteboardState } from './reducer';
const getWhiteboardState = (state: IReduxState): IWhiteboardState => state['features/whiteboard'];
+export const getWhiteboardConfig = (state: IReduxState): IWhiteboardConfig =>
+ state['features/base/config'].whiteboard || {};
+
+const getWhiteboardUserLimit = (state: IReduxState): number => {
+ const userLimit = getWhiteboardConfig(state).userLimit || Infinity;
+
+ return userLimit === Infinity
+ ? userLimit
+ : Math.max(Number(getWhiteboardConfig(state).userLimit || 1), MIN_USER_LIMIT);
+};
+
+/**
+ * Returns the whiteboard collaboration details.
+ *
+ * @param {IReduxState} state - The state from the Redux store.
+ * @returns {{ roomId: string, roomKey: string}|undefined}
+ */
+export const getCollabDetails = (state: IReduxState): {
+ roomId: string; roomKey: string;
+} | undefined => getWhiteboardState(state).collabDetails;
+
/**
* Indicates whether the whiteboard is enabled in the config.
*
@@ -19,11 +41,21 @@ const getWhiteboardState = (state: IReduxState): IWhiteboardState => state['feat
* @returns {boolean}
*/
export const isWhiteboardEnabled = (state: IReduxState): boolean =>
- state['features/base/config'].whiteboard?.enabled
- && state['features/base/config'].whiteboard?.collabServerBaseUrl
+ getWhiteboardConfig(state).enabled
+ && getWhiteboardConfig(state).collabServerBaseUrl
&& getCurrentConference(state)?.getMetadataHandler()
?.isSupported();
+/**
+ * Indicates whether the whiteboard has the collaboration
+ * details and is ready to be used.
+ *
+ * @param {IReduxState} state - The state from the Redux store.
+ * @returns {boolean}
+ */
+export const isWhiteboardReady = (state: IReduxState): boolean =>
+ isWhiteboardEnabled(state) && Boolean(getCollabDetails(state));
+
/**
* Indicates whether the whiteboard is open.
*
@@ -49,16 +81,6 @@ export const isWhiteboardButtonVisible = (state: IReduxState): boolean =>
*/
export const isWhiteboardPresent = (state: IReduxState): boolean => getRemoteParticipants(state).has(WHITEBOARD_ID);
-/**
- * Returns the whiteboard collaboration details.
- *
- * @param {IReduxState} state - The state from the Redux store.
- * @returns {{ roomId: string, roomKey: string}|undefined}
- */
-export const getCollabDetails = (state: IReduxState): {
- roomId: string; roomKey: string;
-} | undefined => getWhiteboardState(state).collabDetails;
-
/**
* Returns the whiteboard collaboration server url.
*
@@ -66,7 +88,7 @@ export const getCollabDetails = (state: IReduxState): {
* @returns {string}
*/
export const getCollabServerUrl = (state: IReduxState): string | undefined => {
- const collabServerBaseUrl = state['features/base/config'].whiteboard?.collabServerBaseUrl;
+ const collabServerBaseUrl = getWhiteboardConfig(state).collabServerBaseUrl;
if (!collabServerBaseUrl) {
return;
@@ -98,3 +120,39 @@ export const isWhiteboardVisible = (state: IReduxState): boolean =>
*/
export const isWhiteboardAllowed = (state: IReduxState): boolean =>
isWhiteboardEnabled(state) && isLocalParticipantModerator(state);
+
+/**
+ * Whether to enforce the whiteboard user limit.
+ *
+ * @param {IReduxState} state - The state from the Redux store.
+ * @returns {boolean}
+ */
+export const shouldEnforceUserLimit = (state: IReduxState): boolean => {
+ const userLimit = getWhiteboardUserLimit(state);
+
+ if (userLimit === Infinity) {
+ return false;
+ }
+
+ const participantCount = getParticipantCount(state);
+
+ return participantCount > userLimit;
+};
+
+/**
+ * Whether to show a warning about the whiteboard user limit.
+ *
+ * @param {IReduxState} state - The state from the Redux store.
+ * @returns {boolean}
+ */
+export const shouldNotifyUserLimit = (state: IReduxState): boolean => {
+ const userLimit = getWhiteboardUserLimit(state);
+
+ if (userLimit === Infinity) {
+ return false;
+ }
+
+ const participantCount = getParticipantCount(state);
+
+ return participantCount + USER_LIMIT_THRESHOLD > userLimit;
+};
diff --git a/react/features/whiteboard/middleware.ts b/react/features/whiteboard/middleware.ts
index 78ed363619..ac8be7e2a6 100644
--- a/react/features/whiteboard/middleware.ts
+++ b/react/features/whiteboard/middleware.ts
@@ -1,8 +1,12 @@
import { generateCollaborationLinkData } from '@jitsi/excalidraw';
import { AnyAction } from 'redux';
+import { createOpenWhiteboardEvent } from '../analytics/AnalyticsEvents';
+import { sendAnalytics } from '../analytics/functions';
import { IStore } from '../app/types';
import { getCurrentConference } from '../base/conference/functions';
+import { hideDialog, openDialog } from '../base/dialog/actions';
+import { isDialogOpen } from '../base/dialog/functions';
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import { participantJoined, participantLeft, pinParticipant } from '../base/participants/actions';
import { FakeParticipant } from '../base/participants/types';
@@ -13,9 +17,23 @@ import { addStageParticipant } from '../filmstrip/actions.web';
import { isStageFilmstripAvailable } from '../filmstrip/functions.web';
import { RESET_WHITEBOARD, SET_WHITEBOARD_OPEN } from './actionTypes';
-import { resetWhiteboard, setWhiteboardOpen, setupWhiteboard } from './actions';
+import {
+ notifyWhiteboardLimit,
+ resetWhiteboard,
+ restrictWhiteboard,
+ setWhiteboardOpen,
+ setupWhiteboard
+} from './actions';
+import WhiteboardLimitDialog from './components/web/WhiteboardLimitDialog';
import { WHITEBOARD_ID, WHITEBOARD_PARTICIPANT_NAME } from './constants';
-import { getCollabDetails, getCollabServerUrl, isWhiteboardPresent } from './functions';
+import {
+ getCollabDetails,
+ getCollabServerUrl,
+ isWhiteboardOpen,
+ isWhiteboardPresent,
+ shouldEnforceUserLimit,
+ shouldNotifyUserLimit
+} from './functions';
import { WhiteboardStatus } from './types';
const focusWhiteboard = (store: IStore) => {
@@ -54,6 +72,15 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => async (action
switch (action.type) {
case SET_WHITEBOARD_OPEN: {
const existingCollabDetails = getCollabDetails(state);
+ const enforceUserLimit = shouldEnforceUserLimit(state);
+ const notifyUserLimit = shouldNotifyUserLimit(state);
+
+ if (enforceUserLimit) {
+ dispatch(restrictWhiteboard(false));
+ dispatch(openDialog(WhiteboardLimitDialog));
+
+ return;
+ }
if (!existingCollabDetails) {
const collabLinkData = await generateCollaborationLinkData();
@@ -76,7 +103,22 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => async (action
}
if (action.isOpen) {
+ if (enforceUserLimit) {
+ dispatch(restrictWhiteboard());
+
+ return;
+ }
+
+ if (notifyUserLimit) {
+ dispatch(notifyWhiteboardLimit());
+ }
+
+ if (isDialogOpen(state, WhiteboardLimitDialog)) {
+ dispatch(hideDialog(WhiteboardLimitDialog));
+ }
+
focusWhiteboard(store);
+ sendAnalytics(createOpenWhiteboardEvent());
raiseWhiteboardNotification(WhiteboardStatus.SHOWN);
return;
@@ -131,3 +173,28 @@ StateListenerRegistry.register(
});
}
});
+
+/**
+ * Set up state change listener to limit whiteboard access.
+ */
+StateListenerRegistry.register(
+ state => shouldEnforceUserLimit(state),
+ (enforceUserLimit, { dispatch, getState }): void => {
+ if (isWhiteboardOpen(getState()) && enforceUserLimit) {
+ dispatch(restrictWhiteboard());
+ }
+ }
+);
+
+/**
+ * Set up state change listener to notify about whiteboard usage.
+ */
+StateListenerRegistry.register(
+ state => shouldNotifyUserLimit(state),
+ (notifyUserLimit, { dispatch, getState }, prevNotifyUserLimit): void => {
+ if (isWhiteboardOpen(getState()) && notifyUserLimit && !prevNotifyUserLimit) {
+ dispatch(notifyWhiteboardLimit());
+ }
+ }
+);
+
diff --git a/react/features/whiteboard/reducer.ts b/react/features/whiteboard/reducer.ts
index 880e082453..f53cf49e83 100644
--- a/react/features/whiteboard/reducer.ts
+++ b/react/features/whiteboard/reducer.ts
@@ -18,7 +18,8 @@ export interface IWhiteboardState {
}
const DEFAULT_STATE: IWhiteboardState = {
- isOpen: false
+ isOpen: false,
+ collabDetails: undefined
};
export interface IWhiteboardAction extends Partial<IWhiteboardState> {