fix: Messages being encrypted for too many devices

This commit is contained in:
Sorunome 2020-10-04 12:16:01 +02:00
parent ae79af6ea8
commit 74bd1d331b
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
3 changed files with 5 additions and 4 deletions

View file

@ -1579,13 +1579,13 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
/// you can safely make this Client instance null. /// you can safely make this Client instance null.
Future<void> dispose({bool closeDatabase = false}) async { Future<void> dispose({bool closeDatabase = false}) async {
_disposed = true; _disposed = true;
encryption?.dispose();
encryption = null;
try { try {
await _currentTransaction; await _currentTransaction;
} catch (_) { } catch (_) {
// No-OP // No-OP
} }
encryption?.dispose();
encryption = null;
try { try {
if (closeDatabase) await database?.close(); if (closeDatabase) await database?.close();
} catch (error, stacktrace) { } catch (error, stacktrace) {

View file

@ -1620,7 +1620,8 @@ class Room {
var deviceKeys = <DeviceKeys>[]; var deviceKeys = <DeviceKeys>[];
var users = await requestParticipants(); var users = await requestParticipants();
for (final user in users) { for (final user in users) {
if (client.userDeviceKeys.containsKey(user.id)) { if ([Membership.invite, Membership.join].contains(user.membership) &&
client.userDeviceKeys.containsKey(user.id)) {
for (var deviceKeyEntry for (var deviceKeyEntry
in client.userDeviceKeys[user.id].deviceKeys.values) { in client.userDeviceKeys[user.id].deviceKeys.values) {
deviceKeys.add(deviceKeyEntry); deviceKeys.add(deviceKeyEntry);

View file

@ -133,7 +133,7 @@ void main() {
expect(user1.canChangePowerLevel, false); expect(user1.canChangePowerLevel, false);
}); });
test('dispose client', () async { test('dispose client', () async {
await client.dispose(); await client.dispose(closeDatabase: true);
}); });
}); });
} }