[MM-63889] Calls: Add backend version check to enable DC locking (#8799) (#8808)

* Calls: Add backend version check to enable DC locking

* Update calls-common

(cherry picked from commit 7192d21134)

Co-authored-by: Claudio Costa <cstcld91@gmail.com>
This commit is contained in:
Mattermost Build 2025-04-29 08:36:48 +03:00 committed by GitHub
parent c3687a6493
commit afc083e2ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 22 additions and 20 deletions

View file

@ -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<CallChannelState[]>;
getCallForChannel: (channelId: string) => Promise<CallChannelState>;
getCallsConfig: (groupLabel?: RequestGroupLabel) => Promise<CallsConfig>;
getVersion: (groupLabel?: RequestGroupLabel) => Promise<CallsVersion>;
getVersion: (groupLabel?: RequestGroupLabel) => Promise<CallsVersionInfo>;
enableChannelCalls: (channelId: string, enable: boolean) => Promise<CallChannelState>;
endCall: (channelId: string) => Promise<ApiResp>;
genTURNCredentials: () => Promise<RTCIceServer[]>;

View file

@ -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',

View file

@ -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();

View file

@ -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;

View file

@ -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,

11
package-lock.json generated
View file

@ -6,7 +6,7 @@
"packages": {
"": {
"name": "mattermost-mobile",
"version": "2.27.0",
"version": "2.28.0",
"hasInstallScript": true,
"license": "Apache 2.0",
"dependencies": {
@ -17,7 +17,7 @@
"@formatjs/intl-numberformat": "8.15.4",
"@formatjs/intl-pluralrules": "5.4.4",
"@gorhom/bottom-sheet": "5.1.2",
"@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",
@ -4825,11 +4825,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": {

View file

@ -18,7 +18,7 @@
"@formatjs/intl-numberformat": "8.15.4",
"@formatjs/intl-pluralrules": "5.4.4",
"@gorhom/bottom-sheet": "5.1.2",
"@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",