Skip to content

Commit

Permalink
Log when OlmMachine returns unexpected value
Browse files Browse the repository at this point in the history
Also condense the validity checks on the returned value
  • Loading branch information
AndrewFerr committed Jul 19, 2023
1 parent 7b97762 commit 58c71bc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/e2ee/CryptoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,12 @@ export class CryptoClient {

await this.engine.lock.acquire(SYNC_LOCK_NAME, async () => {
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);
}
if (Array.isArray(syncResp) && syncResp.length === 2 && Array.isArray(syncResp[0])) {
for (const msg of syncResp[0] as IToDeviceMessage[]) {
this.client.emit("to_device.decrypted", msg);
}
} else {
LogService.error("CryptoClient", "OlmMachine.receiveSyncChanges did not return an expected value of [to-device events, room key changes]");
}

await this.engine.run();
Expand Down

0 comments on commit 58c71bc

Please sign in to comment.