From 08dcce622530590e67fa2c67a56090e4f36c4332 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Wed, 30 Dec 2020 18:50:40 +0100 Subject: [PATCH] chore: Add more debugging logs --- lib/encryption/key_manager.dart | 4 ++++ lib/src/client.dart | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/encryption/key_manager.dart b/lib/encryption/key_manager.dart index d4000651..d0519554 100644 --- a/lib/encryption/key_manager.dart +++ b/lib/encryption/key_manager.dart @@ -911,7 +911,10 @@ class KeyManager { data, ); } else if (event.type == EventTypes.RoomKey) { + Logs().v( + '[KeyManager] Received room key with session ${event.content['session_id']}'); if (event.encryptedContent == null) { + Logs().v('[KeyManager] not encrypted, ignoring...'); return; // the event wasn't encrypted, this is a security risk; } final String roomId = event.content['room_id']; @@ -924,6 +927,7 @@ class KeyManager { .deviceKeys[event.content['requesting_device_id']] .ed25519Key; } + Logs().v('[KeyManager] Keeping room key'); setInboundGroupSession(roomId, sessionId, event.encryptedContent['sender_key'], event.content, forwarded: false); diff --git a/lib/src/client.dart b/lib/src/client.dart index 3df64343..8aad3917 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -994,10 +994,12 @@ class Client extends MatrixApi { } Future _handleToDeviceEvents(List events) async { - for (var i = 0; i < events.length; i++) { - var toDeviceEvent = ToDeviceEvent.fromJson(events[i].toJson()); + for (final event in events) { + var toDeviceEvent = ToDeviceEvent.fromJson(event.toJson()); + Logs().v('Got to_device event of type ${toDeviceEvent.type}'); if (toDeviceEvent.type == EventTypes.Encrypted && encryptionEnabled) { toDeviceEvent = await encryption.decryptToDeviceEvent(toDeviceEvent); + Logs().v('Decrypted type is: ${toDeviceEvent.type}'); } if (encryptionEnabled) { await encryption.handleToDeviceEvent(toDeviceEvent); @@ -1603,6 +1605,7 @@ sort order of ${prevState.sortOrder}. This should never happen...'''); bool onlyVerified = false, }) async { if (!encryptionEnabled) return; + Logs().v('Sending to device message... (${deviceKeys.length} pre-devices)'); // Don't send this message to blocked devices, and if specified onlyVerified // then only send it to verified devices if (deviceKeys.isNotEmpty) { @@ -1612,6 +1615,8 @@ sort order of ${prevState.sortOrder}. This should never happen...'''); (onlyVerified && !deviceKeys.verified)); if (deviceKeys.isEmpty) return; } + Logs().v('Sending to device message... (${deviceKeys.length} pre-devices)'); + Logs().v(deviceKeys.map((k) => '${k.userId}:${k.deviceId}').toList()); // Send with send-to-device messaging var data = >>{};