Skip to content

Commit

Permalink
Pull to-device event list out of returned tuple
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AndrewFerr committed Jul 19, 2023
1 parent 10eb6b3 commit 7b97762
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/e2ee/CryptoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 7b97762

Please sign in to comment.