diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 95e037c84fb..95c39f49a74 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -88,10 +88,7 @@ import * as durations from '../util/durations'; import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary'; import { fetchMembershipProof, getMembershipList } from '../groups'; import type { ProcessedEnvelope } from '../textsecure/Types.d'; -import type { - GetIceServersResultType, - IceServerGroupType, -} from '../textsecure/WebAPI'; +import type { GetIceServersResultType } from '../textsecure/WebAPI'; import { missingCaseError } from '../util/missingCaseError'; import { normalizeGroupCallTimestamp } from '../util/ringrtc/normalizeGroupCallTimestamp'; import { @@ -3148,32 +3145,24 @@ export class CallingClass { function iceServerConfigToList( iceServerConfig: GetIceServersResultType ): Array { - function mapConfig( - iceServerGroup: GetIceServersResultType | IceServerGroupType - ): Array { - if (!iceServerGroup.username || !iceServerGroup.password) { - return []; - } - - return [ - { - hostname: iceServerGroup.hostname ?? '', - username: iceServerGroup.username, - password: iceServerGroup.password, - urls: (iceServerGroup.urlsWithIps ?? []).slice(), - }, - { - hostname: '', - username: iceServerGroup.username, - password: iceServerGroup.password, - urls: (iceServerGroup.urls ?? []).slice(), - }, - ]; + if (!iceServerConfig.relays) { + return []; } - return [iceServerConfig] - .concat(iceServerConfig.iceServers ?? []) - .flatMap(mapConfig); + return iceServerConfig.relays.flatMap(iceServerGroup => [ + { + hostname: iceServerGroup.hostname ?? '', + username: iceServerGroup.username, + password: iceServerGroup.password, + urls: (iceServerGroup.urlsWithIps ?? []).slice(), + }, + { + hostname: '', + username: iceServerGroup.username, + password: iceServerGroup.password, + urls: (iceServerGroup.urls ?? []).slice(), + }, + ]); } if (!window.textsecure.messaging) { diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index c74604c9c5e..1e346276f28 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -626,7 +626,7 @@ const URL_CALLS = { discovery: 'v1/discovery', getGroupAvatarUpload: 'v1/groups/avatar/form', getGroupCredentials: 'v1/certificate/auth/group', - getIceServers: 'v1/calling/relays', + getIceServers: 'v2/calling/relays', getOnboardingStoryManifest: 'dynamic/desktop/stories/onboarding/manifest.json', getStickerPackUpload: 'v1/sticker/pack/form', @@ -902,12 +902,7 @@ export type GetAccountForUsernameResultType = z.infer< >; export type GetIceServersResultType = Readonly<{ - username?: string; - password?: string; - urls?: ReadonlyArray; - urlsWithIps?: ReadonlyArray; - hostname?: string; - iceServers?: ReadonlyArray; + relays?: ReadonlyArray; }>; export type IceServerGroupType = Readonly<{