Skip to content

Commit fef0d54

Browse files
committed
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.
1 parent 73a38c1 commit fef0d54

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/e2ee/CryptoClient.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@ export class CryptoClient {
168168
leftDeviceLists.map(u => new UserId(u)));
169169

170170
await this.engine.lock.acquire(SYNC_LOCK_NAME, async () => {
171-
const syncResp = await this.engine.machine.receiveSyncChanges(deviceMessages, deviceLists, otkCounts, unusedFallbackKeyAlgs);
172-
const decryptedToDeviceMessages = JSON.parse(syncResp);
173-
if (Array.isArray(decryptedToDeviceMessages)) {
174-
for (const msg of decryptedToDeviceMessages) {
175-
this.client.emit("to_device.decrypted", msg);
171+
const syncResp = JSON.parse(await this.engine.machine.receiveSyncChanges(deviceMessages, deviceLists, otkCounts, unusedFallbackKeyAlgs));
172+
if (Array.isArray(syncResp)) {
173+
const decryptedToDeviceMessages = syncResp[0];
174+
if (Array.isArray(decryptedToDeviceMessages)) {
175+
for (const msg of decryptedToDeviceMessages as IToDeviceMessage[]) {
176+
this.client.emit("to_device.decrypted", msg);
177+
}
176178
}
177179
}
178180

0 commit comments

Comments
 (0)