Skip to content

Commit

Permalink
Remove deprecated calls of MatrixClient
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Nov 28, 2024
1 parent 3781b6e commit 5ee0ba2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
6 changes: 4 additions & 2 deletions src/models/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { RelationType } from "../@types/event.ts";
import { TypedEventEmitter } from "./typed-event-emitter.ts";
import { MatrixClient } from "../client.ts";
import { Room } from "./room.ts";
import { CryptoBackend } from "../common-crypto/CryptoBackend.ts";

export enum RelationsEvent {
Add = "Relations.add",
Expand Down Expand Up @@ -323,8 +324,9 @@ export class Relations extends TypedEventEmitter<RelationsEvent, EventHandlerMap
return event;
}, null);

if (lastReplacement?.shouldAttemptDecryption() && this.client.isCryptoEnabled()) {
await lastReplacement.attemptDecryption(this.client.crypto!);
if (lastReplacement?.shouldAttemptDecryption() && this.client.getCrypto()) {
// Dirty but we are expecting to pass the cryptoBackend which is not accessible here
await lastReplacement.attemptDecryption(this.client.getCrypto() as CryptoBackend);
} else if (lastReplacement?.isBeingDecrypted()) {
await lastReplacement.getDecryptionPromise();
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* @returns Signals when all events have been decrypted
*/
public async decryptCriticalEvents(): Promise<void> {
if (!this.client.isCryptoEnabled()) return;
if (!this.client.getCrypto()) return;

const readReceiptEventId = this.getEventReadUpTo(this.client.getUserId()!, true);
const events = this.getLiveTimeline().getEvents();
Expand All @@ -567,7 +567,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* @returns Signals when all events have been decrypted
*/
public async decryptAllEvents(): Promise<void> {
if (!this.client.isCryptoEnabled()) return;
if (!this.client.getCrypto()) return;

const decryptionPromises = this.getUnfilteredTimelineSet()
.getLiveTimeline()
Expand Down
21 changes: 0 additions & 21 deletions src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,27 +1248,6 @@ export class SyncApi {

await this.injectRoomEvents(room, stateEvents, undefined);

const inviter = room.currentState.getStateEvents(EventType.RoomMember, client.getUserId()!)?.getSender();

const crypto = client.crypto;
if (crypto) {
const parkedHistory = await crypto.cryptoStore.takeParkedSharedHistory(room.roomId);
for (const parked of parkedHistory) {
if (parked.senderId === inviter) {
await crypto.olmDevice.addInboundGroupSession(
room.roomId,
parked.senderKey,
parked.forwardingCurve25519KeyChain,
parked.sessionId,
parked.sessionKey,
parked.keysClaimed,
true,
{ sharedHistory: true, untrusted: true },
);
}
}
}

if (inviteObj.isBrandNewRoom) {
room.recalculate();
client.store.storeRoom(room);
Expand Down

0 comments on commit 5ee0ba2

Please sign in to comment.