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(jwt): Use isJwtFeatureEnabled the same way in all places.

damenchoe04db24d1530
diff --git a/react/features/base/jwt/functions.ts b/react/features/base/jwt/functions.ts
index 06f2bbdcc1..f5fa1107c4 100644
--- a/react/features/base/jwt/functions.ts
+++ b/react/features/base/jwt/functions.ts
@@ -48,7 +48,7 @@ export function getJwtName(state: IReduxState) {
* @param {boolean} ifNotInFeatures - Default value if features prop exists but does not have the {@code feature}.
* @returns {boolean}
*/
-export function isJwtFeatureEnabled(state: IReduxState, feature: string, ifNoToken = false, ifNotInFeatures = false) {
+export function isJwtFeatureEnabled(state: IReduxState, feature: string, ifNoToken: boolean, ifNotInFeatures: boolean) {
const { jwt } = state['features/base/jwt'];
const { features } = getLocalParticipant(state) || {};
@@ -63,8 +63,8 @@ export function isJwtFeatureEnabled(state: IReduxState, feature: string, ifNoTok
interface IIsJwtFeatureEnabledStatelessParams {
feature: string;
- ifNoToken?: boolean;
- ifNotInFeatures?: boolean;
+ ifNoToken: boolean;
+ ifNotInFeatures: boolean;
jwt?: string;
localParticipantFeatures?: IParticipantFeatures;
}
@@ -76,23 +76,23 @@ interface IIsJwtFeatureEnabledStatelessParams {
* @param {ILocalParticipant} localParticipantFeatures - The features of the local participant.
* @param {string} feature - The feature we want to check.
* @param {boolean} ifNoToken - Default value if there is no token.
- * @param {boolean} ifNotInFeatures - Default value if features prop exists but does not have the {@code feature}.
- * @returns {bolean}
+ * @param {boolean} ifNotInFeatures - Default value if features is missing
+ * or prop exists but does not have the {@code feature}.
+ * @returns {boolean}
*/
export function isJwtFeatureEnabledStateless({
jwt,
localParticipantFeatures: features,
feature,
- ifNoToken = false,
- ifNotInFeatures = false
+ ifNoToken,
+ ifNotInFeatures
}: IIsJwtFeatureEnabledStatelessParams) {
if (!jwt) {
return ifNoToken;
}
- // If `features` is undefined, act as if everything is enabled.
if (typeof features === 'undefined') {
- return true;
+ return ifNotInFeatures;
}
if (typeof features[feature as keyof typeof features] === 'undefined') {
diff --git a/react/features/recording/actions.any.ts b/react/features/recording/actions.any.ts
index 77975fa566..ae786e0de2 100644
--- a/react/features/recording/actions.any.ts
+++ b/react/features/recording/actions.any.ts
@@ -434,9 +434,8 @@ export function showStartRecordingNotificationWithCallback(openRecordingDialog:
state = getState();
const isModerator = isLocalParticipantModerator(state);
const { recordingService } = state['features/base/config'];
- const canBypassDialog = isModerator
- && recordingService?.enabled
- && isJwtFeatureEnabled(state, 'recording', true);
+ const canBypassDialog = recordingService?.enabled
+ && isJwtFeatureEnabled(state, 'recording', isModerator, isModerator);
if (canBypassDialog) {
const options = {
diff --git a/react/features/recording/functions.ts b/react/features/recording/functions.ts
index ab2e8ccfc6..aae28195ab 100644
--- a/react/features/recording/functions.ts
+++ b/react/features/recording/functions.ts
@@ -203,7 +203,9 @@ export function canStopRecording(state: IReduxState) {
}
if (isCloudRecordingRunning(state) || isRecorderTranscriptionsRunning(state)) {
- return isLocalParticipantModerator(state) && isJwtFeatureEnabled(state, 'recording', true);
+ const isModerator = isLocalParticipantModerator(state);
+
+ return isJwtFeatureEnabled(state, 'recording', isModerator, isModerator);
}
return false;
diff --git a/react/features/toolbox/functions.any.ts b/react/features/toolbox/functions.any.ts
index e8a180cff3..e6ef59856c 100644
--- a/react/features/toolbox/functions.any.ts
+++ b/react/features/toolbox/functions.any.ts
@@ -35,7 +35,8 @@ export function getJwtDisabledButtons(
jwt,
localParticipantFeatures,
feature: 'livestreaming',
- ifNoToken: true
+ ifNoToken: true,
+ ifNotInFeatures: true
})) {
acc.push('livestreaming');
}
@@ -44,7 +45,8 @@ export function getJwtDisabledButtons(
jwt,
localParticipantFeatures,
feature: 'transcription',
- ifNoToken: true
+ ifNoToken: true,
+ ifNotInFeatures: true
})) {
acc.push('closedcaptions');
}