Fix some olm sessions not being loaded from database

This commit is contained in:
Sorunome 2020-06-23 11:42:01 +02:00
parent 5a57c886ae
commit 439f6f0aa0
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C

View file

@ -400,6 +400,18 @@ class OlmManager {
String type,
Map<String, dynamic> payload) async {
var data = <String, Map<String, Map<String, dynamic>>>{};
// 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<DeviceKeys>.from(deviceKeys);
deviceKeysWithoutSession.removeWhere((DeviceKeys deviceKeys) =>
olmSessions.containsKey(deviceKeys.curve25519Key));