diff --git a/spec/unit/rust-crypto/rust-crypto.spec.ts b/spec/unit/rust-crypto/rust-crypto.spec.ts index 22640b9bf..ec816014f 100644 --- a/spec/unit/rust-crypto/rust-crypto.spec.ts +++ b/spec/unit/rust-crypto/rust-crypto.spec.ts @@ -498,7 +498,7 @@ describe("RustCrypto", () => { [RustSdkCryptoJs.ShieldColor.Red, EventShieldColour.RED], ])("gets the right shield color (%i)", async (rustShield, expectedShield) => { const mockEncryptionInfo = { - shieldState: jest.fn().mockReturnValue({ color: rustShield, message: null }), + shieldState: jest.fn().mockReturnValue({ color: rustShield, message: undefined }), } as unknown as RustSdkCryptoJs.EncryptionInfo; olmMachine.getRoomEventEncryptionInfo.mockResolvedValue(mockEncryptionInfo); @@ -509,7 +509,7 @@ describe("RustCrypto", () => { }); it.each([ - [null, null], + [undefined, null], ["Encrypted by an unverified user.", EventShieldReason.UNVERIFIED_IDENTITY], ["Encrypted by a device not verified by its owner.", EventShieldReason.UNSIGNED_DEVICE], [ diff --git a/src/rust-crypto/RoomEncryptor.ts b/src/rust-crypto/RoomEncryptor.ts index 3863c8592..166f9bb93 100644 --- a/src/rust-crypto/RoomEncryptor.ts +++ b/src/rust-crypto/RoomEncryptor.ts @@ -65,15 +65,14 @@ export class RoomEncryptor { * @param member - new membership state */ public onRoomMembership(member: RoomMember): void { - this.prefixedLogger.debug(`${member.membership} event for ${member.userId}`); - if ( member.membership == "join" || (member.membership == "invite" && this.room.shouldEncryptForInvitedMembers()) ) { // make sure we are tracking the deviceList for this user - this.prefixedLogger.debug(`starting to track devices for: ${member.userId}`); - this.olmMachine.updateTrackedUsers([new UserId(member.userId)]); + this.olmMachine.updateTrackedUsers([new UserId(member.userId)]).catch((e) => { + this.prefixedLogger.error("Unable to update tracked users", e); + }); } // TODO: handle leaves (including our own) diff --git a/src/rust-crypto/backup.ts b/src/rust-crypto/backup.ts index f115fee02..9ecb68b35 100644 --- a/src/rust-crypto/backup.ts +++ b/src/rust-crypto/backup.ts @@ -82,7 +82,7 @@ export class RustBackupManager extends TypedEventEmitter { - if (!this.olmMachine.isBackupEnabled()) return null; + if (!(await this.olmMachine.isBackupEnabled())) return null; return this.activeBackupVersion; } diff --git a/src/rust-crypto/rust-crypto.ts b/src/rust-crypto/rust-crypto.ts index 46fe69702..622bae28d 100644 --- a/src/rust-crypto/rust-crypto.ts +++ b/src/rust-crypto/rust-crypto.ts @@ -1223,10 +1223,6 @@ export class RustCrypto extends TypedEventEmitter `${u.userId} (${u.membership})`), - ); await this.olmMachine.updateTrackedUsers(members.map((u) => new RustSdkCryptoJs.UserId(u.userId))); } @@ -1518,7 +1514,10 @@ class EventDecryptor { public constructor(private readonly olmMachine: RustSdkCryptoJs.OlmMachine, private readonly crypto: RustCrypto) {} public async attemptEventDecryption(event: MatrixEvent): Promise { - logger.info("Attempting decryption of event", event); + logger.info( + `Attempting decryption of event ${event.getId()} in ${event.getRoomId()} from ${event.getSender()}`, + ); + // add the event to the pending list *before* attempting to decrypt. // then, if the key turns up while decryption is in progress (and // decryption fails), we will schedule a retry. @@ -1691,7 +1690,7 @@ function rustEncryptionInfoToJsEncryptionInfo( } let shieldReason: EventShieldReason | null; - if (shieldState.message === null) { + if (shieldState.message === undefined) { shieldReason = null; } else if (shieldState.message === "Encrypted by an unverified user.") { // this case isn't actually used with lax shield semantics.