From 7b97762e7bbf21cac54f655b63e81219138e6f19 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 19 Jul 2023 09:02:34 -0400 Subject: [PATCH] Pull to-device event list out of returned tuple OlmMachine.receiveSyncChanges returns an array of [device messages, room key changes], so emit "to_device.decrypted" with that instead of the entire array. Fixes regression introduced by #287. --- src/e2ee/CryptoClient.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/e2ee/CryptoClient.ts b/src/e2ee/CryptoClient.ts index 74ddfb50..0f6d8f63 100644 --- a/src/e2ee/CryptoClient.ts +++ b/src/e2ee/CryptoClient.ts @@ -168,11 +168,13 @@ export class CryptoClient { leftDeviceLists.map(u => new UserId(u))); await this.engine.lock.acquire(SYNC_LOCK_NAME, async () => { - const syncResp = await this.engine.machine.receiveSyncChanges(deviceMessages, deviceLists, otkCounts, unusedFallbackKeyAlgs); - const decryptedToDeviceMessages = JSON.parse(syncResp); - if (Array.isArray(decryptedToDeviceMessages)) { - for (const msg of decryptedToDeviceMessages) { - this.client.emit("to_device.decrypted", msg); + const syncResp = JSON.parse(await this.engine.machine.receiveSyncChanges(deviceMessages, deviceLists, otkCounts, unusedFallbackKeyAlgs)); + if (Array.isArray(syncResp)) { + const decryptedToDeviceMessages = syncResp[0]; + if (Array.isArray(decryptedToDeviceMessages)) { + for (const msg of decryptedToDeviceMessages as IToDeviceMessage[]) { + this.client.emit("to_device.decrypted", msg); + } } }