From b2e1b5f467c961538c3584b5306dd60eb0cd2ed6 Mon Sep 17 00:00:00 2001 From: Claudio Costa Date: Mon, 28 Apr 2025 09:32:00 -0600 Subject: [PATCH] [MM-63889] Calls: Add backend version check to enable DC locking (#8799) (#8809) * Calls: Add backend version check to enable DC locking * Update calls-common --- app/products/calls/client/rest.ts | 6 +++--- .../calls/connection/connection.test.ts | 3 +++ app/products/calls/connection/connection.ts | 7 +++++-- app/products/calls/types/calls.ts | 8 ++------ app/products/calls/utils.ts | 5 ++--- package-lock.json | 20 +++++++++++++++---- package.json | 2 +- 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/app/products/calls/client/rest.ts b/app/products/calls/client/rest.ts index 0454621fd..6645b1927 100644 --- a/app/products/calls/client/rest.ts +++ b/app/products/calls/client/rest.ts @@ -1,8 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type {ApiResp, CallsVersion} from '@calls/types/calls'; -import type {CallChannelState, CallJobState, CallsConfig} from '@mattermost/calls/lib/types'; +import type {ApiResp} from '@calls/types/calls'; +import type {CallChannelState, CallJobState, CallsConfig, CallsVersionInfo} from '@mattermost/calls/lib/types'; import type {RTCIceServer} from 'react-native-webrtc'; export interface ClientCallsMix { @@ -10,7 +10,7 @@ export interface ClientCallsMix { getCalls: (groupLabel?: RequestGroupLabel) => Promise; getCallForChannel: (channelId: string) => Promise; getCallsConfig: (groupLabel?: RequestGroupLabel) => Promise; - getVersion: (groupLabel?: RequestGroupLabel) => Promise; + getVersion: (groupLabel?: RequestGroupLabel) => Promise; enableChannelCalls: (channelId: string, enable: boolean) => Promise; endCall: (channelId: string) => Promise; genTURNCredentials: () => Promise; diff --git a/app/products/calls/connection/connection.test.ts b/app/products/calls/connection/connection.test.ts index c9d733078..53e6721bf 100644 --- a/app/products/calls/connection/connection.test.ts +++ b/app/products/calls/connection/connection.test.ts @@ -44,6 +44,9 @@ describe('newConnection', () => { AllowEnableCalls: true, EnableAV1: true, })), + getVersion: jest.fn(() => ({ + version: '1.7.0', + })), genTURNCredentials: jest.fn(() => Promise.resolve([{ urls: ['turn:turn.example.com'], username: 'user', diff --git a/app/products/calls/connection/connection.ts b/app/products/calls/connection/connection.ts index 356158eab..3fbbc1272 100644 --- a/app/products/calls/connection/connection.ts +++ b/app/products/calls/connection/connection.ts @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import {RTCMonitor, RTCPeer, parseRTCStats} from '@mattermost/calls/lib'; +import {hasDCSignalingLockSupport} from '@mattermost/calls/lib/utils'; import {zlibSync, strToU8} from 'fflate'; import {DeviceEventEmitter, type EmitterSubscription, NativeEventEmitter, NativeModules, Platform} from 'react-native'; import InCallManager from 'react-native-incall-manager'; @@ -88,10 +89,11 @@ export async function newConnection( const credentials = await getServerCredentials(serverUrl); let config; + let version; try { - config = await client.getCallsConfig(); + [config, version] = await Promise.all([client.getCallsConfig(), client.getVersion()]); } catch (err) { - throw new Error(`calls: fetching calls config: ${getFullErrorMessage(err)}`); + throw new Error(`calls: fetching calls config and version info: ${getFullErrorMessage(err)}`); } let av1Support = false; @@ -387,6 +389,7 @@ export async function newConnection( iceServers: iceConfigs || [], logger, dcSignaling: config.EnableDCSignaling, + dcLocking: hasDCSignalingLockSupport(version), }); collectICEStats(); diff --git a/app/products/calls/types/calls.ts b/app/products/calls/types/calls.ts index 9577789dc..8f90710cc 100644 --- a/app/products/calls/types/calls.ts +++ b/app/products/calls/types/calls.ts @@ -7,6 +7,7 @@ import { type CallsConfig, type EmojiData, type UserReactionData, + type CallsVersionInfo, } from '@mattermost/calls/lib/types'; import type UserModel from '@typings/database/models/servers/user'; @@ -153,7 +154,7 @@ export type CallsConfigState = CallsConfig & { AllowEnableCalls: boolean; GroupCallsAllowed: boolean; pluginEnabled: boolean; - version: CallsVersion; + version: CallsVersionInfo; last_retrieved_at: number; } @@ -211,11 +212,6 @@ export type AudioDeviceInfo = { selectedAudioDevice: AudioDevice; }; -export type CallsVersion = { - version?: string; - build?: string; -}; - export type LiveCaptionMobile = { captionId: string; sessionId: string; diff --git a/app/products/calls/utils.ts b/app/products/calls/utils.ts index 2b1917d13..77b5e0db4 100644 --- a/app/products/calls/utils.ts +++ b/app/products/calls/utils.ts @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {makeCallsBaseAndBadgeRGB, rgbToCSS} from '@mattermost/calls'; -import {type CallsConfig, type CallPostProps, isCaption, type Caption, isCallJobMetadata, type CallJobMetadata} from '@mattermost/calls/lib/types'; +import {type CallsConfig, type CallPostProps, isCaption, type Caption, isCallJobMetadata, type CallJobMetadata, type CallsVersionInfo} from '@mattermost/calls/lib/types'; import {Alert} from 'react-native'; import {SelectedTrackType, TextTrackType, type ISO639_1, type SelectedTrack, type TextTracks} from 'react-native-video'; @@ -17,7 +17,6 @@ import type { CallsConfigState, CallSession, CallsTheme, - CallsVersion, } from '@calls/types/calls'; import type PostModel from '@typings/database/models/servers/post'; import type UserModel from '@typings/database/models/servers/user'; @@ -96,7 +95,7 @@ export function isSupportedServerCalls(serverVersion?: string) { return false; } -export function isMultiSessionSupported(callsVersion: CallsVersion) { +export function isMultiSessionSupported(callsVersion: CallsVersionInfo) { return isMinimumServerVersion( callsVersion.version, Calls.MultiSessionCallsVersion.MAJOR_VERSION, diff --git a/package-lock.json b/package-lock.json index 79ae4ff8a..93db4e8aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@formatjs/intl-numberformat": "8.15.1", "@formatjs/intl-pluralrules": "5.4.1", "@gorhom/bottom-sheet": "5.0.6", - "@mattermost/calls": "github:mattermost/calls-common#fe9b2e74328facc46c2d9e3729ec3a9704d7c618", + "@mattermost/calls": "github:mattermost/calls-common#02b04117fcec88f158d3d9ba62546d8d942ed647", "@mattermost/compass-icons": "0.1.48", "@mattermost/hardware-keyboard": "file:./libraries/@mattermost/hardware-keyboard", "@mattermost/react-native-emm": "1.6.1", @@ -4596,11 +4596,12 @@ "node_modules/@mattermost/calls": { "name": "@mattermost/calls-common", "version": "0.27.2", - "resolved": "git+ssh://git@github.com/mattermost/calls-common.git#fe9b2e74328facc46c2d9e3729ec3a9704d7c618", - "integrity": "sha512-Wj2fclEcPVWYtX7WdrMOaLHXS2AP3y2x8Py9FqHyhoNNY9yUg+ihocUKDKpRwqfu1qM/R02Y26d/g6Mc4+yddg==", + "resolved": "git+ssh://git@github.com/mattermost/calls-common.git#02b04117fcec88f158d3d9ba62546d8d942ed647", + "integrity": "sha512-jHlw8b8k0LrOyAzh/6cSnTg3GHL3yJEZhtNhjvvfEnmxso2CzproEX7juzATtMy0Z1NXOLgdBrn/M0naPxJqgA==", "dependencies": { "@msgpack/msgpack": "3.0.0-beta2", - "fflate": "0.8.2" + "fflate": "0.8.2", + "semver": "7.7.1" } }, "node_modules/@mattermost/calls/node_modules/@msgpack/msgpack": { @@ -4610,6 +4611,17 @@ "node": ">= 14" } }, + "node_modules/@mattermost/calls/node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@mattermost/commonmark": { "version": "0.30.1-2", "license": "BSD-2-Clause", diff --git a/package.json b/package.json index 903bffa1c..c667bd6d4 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@formatjs/intl-numberformat": "8.15.1", "@formatjs/intl-pluralrules": "5.4.1", "@gorhom/bottom-sheet": "5.0.6", - "@mattermost/calls": "github:mattermost/calls-common#fe9b2e74328facc46c2d9e3729ec3a9704d7c618", + "@mattermost/calls": "github:mattermost/calls-common#02b04117fcec88f158d3d9ba62546d8d942ed647", "@mattermost/compass-icons": "0.1.48", "@mattermost/hardware-keyboard": "file:./libraries/@mattermost/hardware-keyboard", "@mattermost/react-native-emm": "1.6.1",