Skip to content

Commit

Permalink
Remove deprecated DeviceInfo in webrtc/call.ts (#4654)
Browse files Browse the repository at this point in the history
* chore(legacy call): Remove `DeviceInfo` usage

* refactor(legacy call): throw `GroupCallUnknownDeviceError` at the end of `initOpponentCrypto`
  • Loading branch information
florianduros authored Jan 27, 2025
1 parent 8537aee commit f763192
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/webrtc/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {
import { CallFeed } from "./callFeed.ts";
import { MatrixClient } from "../client.ts";
import { EventEmitterEvents, TypedEventEmitter } from "../models/typed-event-emitter.ts";
import { DeviceInfo } from "../crypto/deviceinfo.ts";
import { GroupCallUnknownDeviceError } from "./groupCall.ts";
import { IScreensharingOpts } from "./mediaHandler.ts";
import { MatrixError } from "../http-api/index.ts";
Expand Down Expand Up @@ -426,7 +425,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
private callStartTime?: number;

private opponentDeviceId?: string;
private opponentDeviceInfo?: DeviceInfo;
private hasOpponentDeviceInfo?: boolean;
private opponentSessionId?: string;
public groupCallId?: string;

Expand Down Expand Up @@ -633,19 +632,16 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
// ourselves (for example if the client is a RoomWidgetClient)
if (!this.client.getCrypto()) {
// All we know is the device ID
this.opponentDeviceInfo = new DeviceInfo(this.opponentDeviceId);
this.hasOpponentDeviceInfo = true;
return;
}
const userId = this.invitee || this.getOpponentMember()?.userId;

if (!userId) throw new Error("Couldn't find opponent user ID to init crypto");

// Here we were calling `MatrixClient.crypto.deviceList.downloadKeys` which is not supported by the rust cryptography.
const deviceInfoMap = new Map();
this.opponentDeviceInfo = deviceInfoMap.get(userId)?.get(this.opponentDeviceId);
if (this.opponentDeviceInfo === undefined) {
throw new GroupCallUnknownDeviceError(userId);
}
this.hasOpponentDeviceInfo = false;
throw new GroupCallUnknownDeviceError(userId);
}

/**
Expand Down Expand Up @@ -2509,7 +2505,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap

const userId = this.invitee || this.getOpponentMember()!.userId;
if (this.client.getUseE2eForGroupCall()) {
if (!this.opponentDeviceInfo) {
if (!this.hasOpponentDeviceInfo) {
logger.warn(`Call ${this.callId} sendVoipEvent() failed: we do not have opponentDeviceInfo`);
return;
}
Expand Down

0 comments on commit f763192

Please sign in to comment.