Skip to content

Commit

Permalink
Remove deprecated calls in webrtc/call.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Nov 28, 2024
1 parent 3781b6e commit add17fb
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/webrtc/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ 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";
import { GroupCallStats } from "./stats/groupCallStats.ts";
import { GroupCallUnknownDeviceError } from "./groupCall.ts";

interface CallOpts {
// The room ID for this call.
Expand Down Expand Up @@ -631,19 +631,17 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
if (!this.client.getUseE2eForGroupCall()) return;
// It's possible to want E2EE and yet not have the means to manage E2EE
// ourselves (for example if the client is a RoomWidgetClient)
if (!this.client.isCryptoEnabled()) {
if (!this.client.getCrypto()) {
// All we know is the device ID
this.opponentDeviceInfo = new DeviceInfo(this.opponentDeviceId);
return;
}
// if we've got to this point, we do want to init crypto, so throw if we can't
if (!this.client.crypto) throw new Error("Crypto is not initialised.");

const userId = this.invitee || this.getOpponentMember()?.userId;

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

const deviceInfoMap = await this.client.crypto.deviceList.downloadKeys([userId], false);
// 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);
Expand Down Expand Up @@ -2516,18 +2514,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
return;
}

await this.client.encryptAndSendToDevices(
[
{
userId,
deviceInfo: this.opponentDeviceInfo,
},
],
{
type: eventType,
content,
},
);
// Here we were calling `MatrixClient.encryptAndSendToDevices` which is not supported by the rust cryptography.
} else {
await this.client.sendToDevice(
eventType,
Expand Down Expand Up @@ -2869,7 +2856,8 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
this.checkForErrorListener();
this.direction = CallDirection.Outbound;

await this.initOpponentCrypto();
// Here we were initializing the opponent crypto
// It was removed because it was calling deprecated methods which were not working since the rust crypto migration.

// XXX Find a better way to do this
this.client.callEventHandler!.calls.set(this.callId, this);
Expand Down

0 comments on commit add17fb

Please sign in to comment.