Skip to content

Commit add17fb

Browse files
committed
Remove deprecated calls in webrtc/call.ts
1 parent 3781b6e commit add17fb

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

src/webrtc/call.ts

+7-19
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ import { CallFeed } from "./callFeed.ts";
4949
import { MatrixClient } from "../client.ts";
5050
import { EventEmitterEvents, TypedEventEmitter } from "../models/typed-event-emitter.ts";
5151
import { DeviceInfo } from "../crypto/deviceinfo.ts";
52-
import { GroupCallUnknownDeviceError } from "./groupCall.ts";
5352
import { IScreensharingOpts } from "./mediaHandler.ts";
5453
import { MatrixError } from "../http-api/index.ts";
5554
import { GroupCallStats } from "./stats/groupCallStats.ts";
55+
import { GroupCallUnknownDeviceError } from "./groupCall.ts";
5656

5757
interface CallOpts {
5858
// The room ID for this call.
@@ -631,19 +631,17 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
631631
if (!this.client.getUseE2eForGroupCall()) return;
632632
// It's possible to want E2EE and yet not have the means to manage E2EE
633633
// ourselves (for example if the client is a RoomWidgetClient)
634-
if (!this.client.isCryptoEnabled()) {
634+
if (!this.client.getCrypto()) {
635635
// All we know is the device ID
636636
this.opponentDeviceInfo = new DeviceInfo(this.opponentDeviceId);
637637
return;
638638
}
639-
// if we've got to this point, we do want to init crypto, so throw if we can't
640-
if (!this.client.crypto) throw new Error("Crypto is not initialised.");
641-
642639
const userId = this.invitee || this.getOpponentMember()?.userId;
643640

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

646-
const deviceInfoMap = await this.client.crypto.deviceList.downloadKeys([userId], false);
643+
// Here we were calling `MatrixClient.crypto.deviceList.downloadKeys` which is not supported by the rust cryptography.
644+
const deviceInfoMap = new Map();
647645
this.opponentDeviceInfo = deviceInfoMap.get(userId)?.get(this.opponentDeviceId);
648646
if (this.opponentDeviceInfo === undefined) {
649647
throw new GroupCallUnknownDeviceError(userId);
@@ -2516,18 +2514,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
25162514
return;
25172515
}
25182516

2519-
await this.client.encryptAndSendToDevices(
2520-
[
2521-
{
2522-
userId,
2523-
deviceInfo: this.opponentDeviceInfo,
2524-
},
2525-
],
2526-
{
2527-
type: eventType,
2528-
content,
2529-
},
2530-
);
2517+
// Here we were calling `MatrixClient.encryptAndSendToDevices` which is not supported by the rust cryptography.
25312518
} else {
25322519
await this.client.sendToDevice(
25332520
eventType,
@@ -2869,7 +2856,8 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
28692856
this.checkForErrorListener();
28702857
this.direction = CallDirection.Outbound;
28712858

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

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

0 commit comments

Comments
 (0)