From bba53b34779ea4eed8db6976dcb95858ab2068dc Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 11 Sep 2020 12:08:06 +0200 Subject: [PATCH] dont store duplicated key values for replay detection --- src/matrix/e2ee/megolm/decryption/DecryptionChanges.js | 5 +---- src/matrix/storage/idb/stores/GroupSessionDecryptionStore.js | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/matrix/e2ee/megolm/decryption/DecryptionChanges.js b/src/matrix/e2ee/megolm/decryption/DecryptionChanges.js index 5597aaf7..10a2da87 100644 --- a/src/matrix/e2ee/megolm/decryption/DecryptionChanges.js +++ b/src/matrix/e2ee/megolm/decryption/DecryptionChanges.js @@ -66,10 +66,7 @@ export class DecryptionChanges { } if (!decryption) { - txn.groupSessionDecryptions.set({ - roomId, - sessionId, - messageIndex, + txn.groupSessionDecryptions.set(roomId, sessionId, messageIndex, { eventId, timestamp }); diff --git a/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.js b/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.js index 99ededb9..8f8df3e7 100644 --- a/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.js +++ b/src/matrix/storage/idb/stores/GroupSessionDecryptionStore.js @@ -27,8 +27,8 @@ export class GroupSessionDecryptionStore { return this._store.get(encodeKey(roomId, sessionId, messageIndex)); } - set(decryption) { - decryption.key = encodeKey(decryption.roomId, decryption.sessionId, decryption.messageIndex); + set(roomId, sessionId, messageIndex, decryption) { + decryption.key = encodeKey(roomId, sessionId, messageIndex); this._store.put(decryption); } }