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(client-requirements): notify the user when the client needs an update. (#17730)

bgrozevdaec0d49a0fb
diff --git a/config.js b/config.js
index 8915cce855..ab684de5a4 100644
--- a/config.js
+++ b/config.js
@@ -1680,6 +1680,11 @@ var config = {
// Hides the participants stats
// hideParticipantsStats: true,
+ // Hides the warning which is shown when the server signals that this client does not advertise a capability that
+ // the deployment expects (i.e. that the client needs an update). The error which is shown when the client is not
+ // allowed in the conference at all is always shown.
+ // hideMissingCapabilityWarnings: false,
+
// Sets the conference subject
// subject: 'Conference Subject',
diff --git a/lang/main.json b/lang/main.json
index c3fb30f6da..cd653ffb3d 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -188,6 +188,13 @@
"dontShowAgain": "Don't show me this again",
"installExtensionText": "Install the extension for Google Calendar and Office 365 integration"
},
+ "clientRequirements": {
+ "rejectDescription": "This app version can not send or receive audio or video in this meeting.",
+ "rejectTitle": "An update is required",
+ "seeDetails": "See details here",
+ "warnDescription": "This app version is missing a feature that this meeting uses. Please update it.",
+ "warnTitle": "An update is recommended"
+ },
"closedCaptionsTab": {
"emptyState": "The closed captions content will be available once a moderator starts it",
"startClosedCaptionsButton": "Start closed captions"
diff --git a/react/features/app/middlewares.any.ts b/react/features/app/middlewares.any.ts
index 232fdf0e19..3acb192b3d 100644
--- a/react/features/app/middlewares.any.ts
+++ b/react/features/app/middlewares.any.ts
@@ -22,6 +22,7 @@ import '../base/user-interaction/middleware';
import '../breakout-rooms/middleware';
import '../calendar-sync/middleware';
import '../chat/middleware';
+import '../client-requirements/middleware';
import '../conference/middleware';
import '../connection-indicator/middleware';
import '../device-selection/middleware';
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 52427000c6..70bc580397 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -515,6 +515,7 @@ export interface IConfig {
*/
hideLobbyButton?: boolean;
hideLoginButton?: boolean;
+ hideMissingCapabilityWarnings?: boolean;
hideParticipantsStats?: boolean;
hideRecordingLabel?: boolean;
hosts?: {
diff --git a/react/features/base/config/configWhitelist.ts b/react/features/base/config/configWhitelist.ts
index 340dacd1fe..f18eef28fe 100644
--- a/react/features/base/config/configWhitelist.ts
+++ b/react/features/base/config/configWhitelist.ts
@@ -172,6 +172,7 @@ export default [
'hideAddRoomButton',
'hideEmailInSettings',
'hideLobbyButton',
+ 'hideMissingCapabilityWarnings',
'iAmRecorder',
'iAmSipGateway',
'iAmSpot',
diff --git a/react/features/client-requirements/functions.native.ts b/react/features/client-requirements/functions.native.ts
new file mode 100644
index 0000000000..be52a98500
--- /dev/null
+++ b/react/features/client-requirements/functions.native.ts
@@ -0,0 +1,29 @@
+import { BUTTON_TYPES } from '../base/ui/constants.native';
+import { openURLInBrowser } from '../base/util/openURLInBrowser';
+import { INotificationProps } from '../notifications/types';
+
+/**
+ * Builds the description of a notification about missing capabilities. A URL is shown as a button, because the native
+ * notification renders text only, and we do not want to show a URL to the user.
+ *
+ * @param {string} text - The text which describes the missing capabilities.
+ * @param {string|undefined} url - A URL with more information, if the server sent one.
+ * @param {Function} _t - The translation function. Not needed here, the button uses a translation key.
+ * @returns {Object} The description properties of the notification.
+ */
+export function getDescriptionProps(text: string, url: string | undefined, _t: Function): INotificationProps {
+ if (!url) {
+ return { description: text };
+ }
+
+ return {
+ customActionHandler: [ () => {
+ openURLInBrowser(url);
+
+ return false;
+ } ],
+ customActionNameKey: [ 'clientRequirements.seeDetails' ],
+ customActionType: [ BUTTON_TYPES.PRIMARY ],
+ description: text
+ };
+}
diff --git a/react/features/client-requirements/functions.web.tsx b/react/features/client-requirements/functions.web.tsx
new file mode 100644
index 0000000000..302abde714
--- /dev/null
+++ b/react/features/client-requirements/functions.web.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+
+import { INotificationProps } from '../notifications/types';
+
+/**
+ * Builds the description of a notification about missing capabilities. The link is rendered around a part of the
+ * text, so that no URL is shown to the user.
+ *
+ * @param {string} text - The text which describes the missing capabilities.
+ * @param {string|undefined} url - A URL with more information, if the server sent one.
+ * @param {Function} t - The translation function.
+ * @returns {Object} The description properties of the notification.
+ */
+export function getDescriptionProps(text: string, url: string | undefined, t: Function): INotificationProps {
+ if (!url) {
+ return { description: text };
+ }
+
+ return {
+ description: (
+ <span>
+ { `${text} ` }
+ <a
+ href = { url }
+ rel = 'noopener noreferrer'
+ target = '_blank'>
+ { t('clientRequirements.seeDetails') }
+ </a>
+ </span>
+ )
+ };
+}
diff --git a/react/features/client-requirements/logger.ts b/react/features/client-requirements/logger.ts
new file mode 100644
index 0000000000..33444da7d2
--- /dev/null
+++ b/react/features/client-requirements/logger.ts
@@ -0,0 +1,3 @@
+import { getLogger } from '../base/logging/functions';
+
+export default getLogger('app:clientRequirements');
diff --git a/react/features/client-requirements/middleware.ts b/react/features/client-requirements/middleware.ts
new file mode 100644
index 0000000000..0f0634f833
--- /dev/null
+++ b/react/features/client-requirements/middleware.ts
@@ -0,0 +1,93 @@
+import i18n from 'i18next';
+
+import { IStore } from '../app/types';
+import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
+import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
+import { showErrorNotification, showWarningNotification } from '../notifications/actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
+
+import { getDescriptionProps } from './functions';
+import logger from './logger';
+import { IClientRequirements, IMissingFeature } from './types';
+
+/**
+ * Middleware that handles the server signaling that this client does not advertise capabilities that the deployment
+ * requires.
+ *
+ * @param {IStore} store - The redux store.
+ * @returns {Function}
+ */
+MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: any) => {
+ switch (action.type) {
+ case CONFERENCE_JOINED: {
+ action.conference.on(
+ JitsiConferenceEvents.CLIENT_REQUIREMENTS_NOT_MET,
+ (requirements: IClientRequirements) => _onClientRequirements(store, requirements));
+
+ break;
+ }
+ }
+
+ return next(action);
+});
+
+/**
+ * Describes a missing capability to the user. Uses a translation for the capability if this client has one, and
+ * otherwise the description that the server sent.
+ *
+ * @param {IMissingFeature} missingFeature - The missing capability.
+ * @returns {string}
+ */
+function _getFeatureText(missingFeature: IMissingFeature): string {
+ const key = `clientRequirements.features.${missingFeature.name}`;
+
+ if (missingFeature.name && i18n.exists(key)) {
+ return i18n.t(key);
+ }
+
+ return missingFeature.details ?? missingFeature.name ?? missingFeature.feature;
+}
+
+/**
+ * Notifies the user that this client does not advertise capabilities that the deployment requires.
+ *
+ * @param {IStore} store - The redux store.
+ * @param {IClientRequirements} requirements - The capabilities that the client is missing, and what the server did
+ * about it.
+ * @returns {void}
+ */
+function _onClientRequirements({ dispatch, getState }: IStore, requirements: IClientRequirements) {
+ const { action, features } = requirements;
+
+ if (!features?.length) {
+ return;
+ }
+
+ logger.warn(`This client is missing required capabilities (action=${action}): `
+ + `${features.map(f => f.name ?? f.feature).join(', ')}`);
+
+ const isReject = action === 'reject';
+
+ if (!isReject && getState()['features/base/config'].hideMissingCapabilityWarnings) {
+ return;
+ }
+
+ const descriptionKey = isReject ? 'clientRequirements.rejectDescription' : 'clientRequirements.warnDescription';
+ const text = [ i18n.t(descriptionKey) ].concat(features.map(_getFeatureText)).join(' ');
+
+ // The first URL that the server sent, if any.
+ const url = features.find(feature => feature.url)?.url;
+ const notification = {
+ ...getDescriptionProps(text, url, i18n.t.bind(i18n)),
+ hideErrorSupportLink: true,
+ titleKey: isReject ? 'clientRequirements.rejectTitle' : 'clientRequirements.warnTitle'
+ };
+
+ if (isReject) {
+ // We are not in the conference and can not send or receive media. Show this even if warnings are hidden.
+ dispatch(showErrorNotification(notification, NOTIFICATION_TIMEOUT_TYPE.STICKY));
+ } else {
+ dispatch(showWarningNotification(notification, NOTIFICATION_TIMEOUT_TYPE.LONG));
+ }
+}
diff --git a/react/features/client-requirements/types.ts b/react/features/client-requirements/types.ts
new file mode 100644
index 0000000000..c3bbd972ff
--- /dev/null
+++ b/react/features/client-requirements/types.ts
@@ -0,0 +1,46 @@
+/**
+ * A capability that this client does not advertise, but the deployment requires.
+ */
+export interface IMissingFeature {
+
+ /**
+ * Text (in English) from the server, which describes how to add support for the capability.
+ */
+ details?: string;
+
+ /**
+ * The XMPP feature (the disco#info "var"), e.g. "http://jitsi.org/ssrc-rewriting-1".
+ */
+ feature: string;
+
+ /**
+ * How severe the missing capability is. With 'hard' the client is not invited to the conference.
+ */
+ level: string;
+
+ /**
+ * A stable symbolic name for the capability, e.g. "SSRC_REWRITING_V1". Used as a translation key.
+ */
+ name?: string;
+
+ /**
+ * A URL with more information.
+ */
+ url?: string;
+}
+
+/**
+ * The capabilities that this client is missing, and what the server did about it.
+ */
+export interface IClientRequirements {
+
+ /**
+ * Either 'reject' (this client is not invited to the conference, i.e. it can not send or receive media) or 'warn'.
+ */
+ action: string;
+
+ /**
+ * The capabilities that this client does not advertise.
+ */
+ features: IMissingFeature[];
+}