From ceb1cd9673b53ce7ee0183251a954c5f59e8b167 Mon Sep 17 00:00:00 2001 From: Horatiu Muresan Date: Mon, 17 Oct 2022 18:32:18 +0300 Subject: [PATCH] fix(screenshare-jwt) Disable screen share based on jwt --- react/features/base/jwt/functions.ts | 9 +++++++-- react/features/toolbox/functions.web.ts | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/react/features/base/jwt/functions.ts b/react/features/base/jwt/functions.ts index 5b5970412..e2fbe3431 100644 --- a/react/features/base/jwt/functions.ts +++ b/react/features/base/jwt/functions.ts @@ -39,9 +39,10 @@ export function getJwtName(state: IState) { * @param {IState} state - The app state. * @param {string} feature - The feature we want to check. * @param {boolean} ifNoToken - Default value if there is no token. - * @returns {string} + * @param {boolean} ifNotInFeatures - Default value if features prop exists but does not have the {@code feature}. + * @returns {bolean} */ -export function isJwtFeatureEnabled(state: IState, feature: string, ifNoToken = false) { +export function isJwtFeatureEnabled(state: IState, feature: string, ifNoToken = false, ifNotInFeatures = false) { const { jwt } = state['features/base/jwt']; if (!jwt) { @@ -55,6 +56,10 @@ export function isJwtFeatureEnabled(state: IState, feature: string, ifNoToken = return true; } + if (typeof features[feature as keyof typeof features] === 'undefined') { + return ifNotInFeatures; + } + return String(features[feature as keyof typeof features]) === 'true'; } diff --git a/react/features/toolbox/functions.web.ts b/react/features/toolbox/functions.web.ts index 7054987f7..6151e15f1 100644 --- a/react/features/toolbox/functions.web.ts +++ b/react/features/toolbox/functions.web.ts @@ -1,6 +1,8 @@ import { IState } from '../app/types'; import { getToolbarButtons } from '../base/config/functions.web'; import { hasAvailableDevices } from '../base/devices/functions'; +import { MEET_FEATURES } from '../base/jwt/constants'; +import { isJwtFeatureEnabled } from '../base/jwt/functions'; import { isScreenMediaShared } from '../screen-share/functions'; import { isWhiteboardVisible } from '../whiteboard/functions'; @@ -84,8 +86,9 @@ export function isAudioSettingsButtonDisabled(state: IState) { export function isDesktopShareButtonDisabled(state: IState) { const { muted, unmuteBlocked } = state['features/base/media'].video; const videoOrShareInProgress = !muted || isScreenMediaShared(state); + const enabledInJwt = isJwtFeatureEnabled(state, MEET_FEATURES.SCREEN_SHARING, true, true); - return unmuteBlocked && !videoOrShareInProgress; + return !enabledInJwt || (unmuteBlocked && !videoOrShareInProgress); } /**