Skip to content

Commit b2e1b5f

Browse files
authored
[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
1 parent a255fef commit b2e1b5f

File tree

7 files changed

+32
-19
lines changed

7 files changed

+32
-19
lines changed

app/products/calls/client/rest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
22
// See LICENSE.txt for license information.
33

4-
import type {ApiResp, CallsVersion} from '@calls/types/calls';
5-
import type {CallChannelState, CallJobState, CallsConfig} from '@mattermost/calls/lib/types';
4+
import type {ApiResp} from '@calls/types/calls';
5+
import type {CallChannelState, CallJobState, CallsConfig, CallsVersionInfo} from '@mattermost/calls/lib/types';
66
import type {RTCIceServer} from 'react-native-webrtc';
77

88
export interface ClientCallsMix {
99
getEnabled: () => Promise<Boolean>;
1010
getCalls: (groupLabel?: RequestGroupLabel) => Promise<CallChannelState[]>;
1111
getCallForChannel: (channelId: string) => Promise<CallChannelState>;
1212
getCallsConfig: (groupLabel?: RequestGroupLabel) => Promise<CallsConfig>;
13-
getVersion: (groupLabel?: RequestGroupLabel) => Promise<CallsVersion>;
13+
getVersion: (groupLabel?: RequestGroupLabel) => Promise<CallsVersionInfo>;
1414
enableChannelCalls: (channelId: string, enable: boolean) => Promise<CallChannelState>;
1515
endCall: (channelId: string) => Promise<ApiResp>;
1616
genTURNCredentials: () => Promise<RTCIceServer[]>;

app/products/calls/connection/connection.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ describe('newConnection', () => {
4444
AllowEnableCalls: true,
4545
EnableAV1: true,
4646
})),
47+
getVersion: jest.fn(() => ({
48+
version: '1.7.0',
49+
})),
4750
genTURNCredentials: jest.fn(() => Promise.resolve([{
4851
urls: ['turn:turn.example.com'],
4952
username: 'user',

app/products/calls/connection/connection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See LICENSE.txt for license information.
33

44
import {RTCMonitor, RTCPeer, parseRTCStats} from '@mattermost/calls/lib';
5+
import {hasDCSignalingLockSupport} from '@mattermost/calls/lib/utils';
56
import {zlibSync, strToU8} from 'fflate';
67
import {DeviceEventEmitter, type EmitterSubscription, NativeEventEmitter, NativeModules, Platform} from 'react-native';
78
import InCallManager from 'react-native-incall-manager';
@@ -88,10 +89,11 @@ export async function newConnection(
8889
const credentials = await getServerCredentials(serverUrl);
8990

9091
let config;
92+
let version;
9193
try {
92-
config = await client.getCallsConfig();
94+
[config, version] = await Promise.all([client.getCallsConfig(), client.getVersion()]);
9395
} catch (err) {
94-
throw new Error(`calls: fetching calls config: ${getFullErrorMessage(err)}`);
96+
throw new Error(`calls: fetching calls config and version info: ${getFullErrorMessage(err)}`);
9597
}
9698

9799
let av1Support = false;
@@ -387,6 +389,7 @@ export async function newConnection(
387389
iceServers: iceConfigs || [],
388390
logger,
389391
dcSignaling: config.EnableDCSignaling,
392+
dcLocking: hasDCSignalingLockSupport(version),
390393
});
391394

392395
collectICEStats();

app/products/calls/types/calls.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
type CallsConfig,
88
type EmojiData,
99
type UserReactionData,
10+
type CallsVersionInfo,
1011
} from '@mattermost/calls/lib/types';
1112

1213
import type UserModel from '@typings/database/models/servers/user';
@@ -153,7 +154,7 @@ export type CallsConfigState = CallsConfig & {
153154
AllowEnableCalls: boolean;
154155
GroupCallsAllowed: boolean;
155156
pluginEnabled: boolean;
156-
version: CallsVersion;
157+
version: CallsVersionInfo;
157158
last_retrieved_at: number;
158159
}
159160

@@ -211,11 +212,6 @@ export type AudioDeviceInfo = {
211212
selectedAudioDevice: AudioDevice;
212213
};
213214

214-
export type CallsVersion = {
215-
version?: string;
216-
build?: string;
217-
};
218-
219215
export type LiveCaptionMobile = {
220216
captionId: string;
221217
sessionId: string;

app/products/calls/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// See LICENSE.txt for license information.
33

44
import {makeCallsBaseAndBadgeRGB, rgbToCSS} from '@mattermost/calls';
5-
import {type CallsConfig, type CallPostProps, isCaption, type Caption, isCallJobMetadata, type CallJobMetadata} from '@mattermost/calls/lib/types';
5+
import {type CallsConfig, type CallPostProps, isCaption, type Caption, isCallJobMetadata, type CallJobMetadata, type CallsVersionInfo} from '@mattermost/calls/lib/types';
66
import {Alert} from 'react-native';
77
import {SelectedTrackType, TextTrackType, type ISO639_1, type SelectedTrack, type TextTracks} from 'react-native-video';
88

@@ -17,7 +17,6 @@ import type {
1717
CallsConfigState,
1818
CallSession,
1919
CallsTheme,
20-
CallsVersion,
2120
} from '@calls/types/calls';
2221
import type PostModel from '@typings/database/models/servers/post';
2322
import type UserModel from '@typings/database/models/servers/user';
@@ -96,7 +95,7 @@ export function isSupportedServerCalls(serverVersion?: string) {
9695
return false;
9796
}
9897

99-
export function isMultiSessionSupported(callsVersion: CallsVersion) {
98+
export function isMultiSessionSupported(callsVersion: CallsVersionInfo) {
10099
return isMinimumServerVersion(
101100
callsVersion.version,
102101
Calls.MultiSessionCallsVersion.MAJOR_VERSION,

package-lock.json

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@formatjs/intl-numberformat": "8.15.1",
1919
"@formatjs/intl-pluralrules": "5.4.1",
2020
"@gorhom/bottom-sheet": "5.0.6",
21-
"@mattermost/calls": "github:mattermost/calls-common#fe9b2e74328facc46c2d9e3729ec3a9704d7c618",
21+
"@mattermost/calls": "github:mattermost/calls-common#02b04117fcec88f158d3d9ba62546d8d942ed647",
2222
"@mattermost/compass-icons": "0.1.48",
2323
"@mattermost/hardware-keyboard": "file:./libraries/@mattermost/hardware-keyboard",
2424
"@mattermost/react-native-emm": "1.6.1",

0 commit comments

Comments
 (0)