From 439f6f0aa06b194d43413a45cf5fd3b005b1b2b2 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Tue, 23 Jun 2020 11:42:01 +0200 Subject: [PATCH] Fix some olm sessions not being loaded from database --- lib/encryption/olm_manager.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index e116dc7..43871c0 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -400,6 +400,18 @@ class OlmManager { String type, Map payload) async { var data = >>{}; + // first check if any of our sessions we want to encrypt for are in the database + if (client.database != null) { + for (final device in deviceKeys) { + if (!olmSessions.containsKey(device.curve25519Key)) { + final sessions = await client.database.getSingleOlmSessions( + client.id, device.curve25519Key, client.userID); + if (sessions.isNotEmpty) { + _olmSessions[device.curve25519Key] = sessions; + } + } + } + } final deviceKeysWithoutSession = List.from(deviceKeys); deviceKeysWithoutSession.removeWhere((DeviceKeys deviceKeys) => olmSessions.containsKey(deviceKeys.curve25519Key));