Merge branch 'soru/debug-logs' into 'main'

chore: Add more debugging logs

See merge request famedly/famedlysdk!594
This commit is contained in:
Sorunome 2020-12-30 17:54:00 +00:00
commit 65d07609d4
2 changed files with 11 additions and 2 deletions

View File

@ -911,7 +911,10 @@ class KeyManager {
data, data,
); );
} else if (event.type == EventTypes.RoomKey) { } else if (event.type == EventTypes.RoomKey) {
Logs().v(
'[KeyManager] Received room key with session ${event.content['session_id']}');
if (event.encryptedContent == null) { if (event.encryptedContent == null) {
Logs().v('[KeyManager] not encrypted, ignoring...');
return; // the event wasn't encrypted, this is a security risk; return; // the event wasn't encrypted, this is a security risk;
} }
final String roomId = event.content['room_id']; final String roomId = event.content['room_id'];
@ -924,6 +927,7 @@ class KeyManager {
.deviceKeys[event.content['requesting_device_id']] .deviceKeys[event.content['requesting_device_id']]
.ed25519Key; .ed25519Key;
} }
Logs().v('[KeyManager] Keeping room key');
setInboundGroupSession(roomId, sessionId, setInboundGroupSession(roomId, sessionId,
event.encryptedContent['sender_key'], event.content, event.encryptedContent['sender_key'], event.content,
forwarded: false); forwarded: false);

View File

@ -994,10 +994,12 @@ class Client extends MatrixApi {
} }
Future<void> _handleToDeviceEvents(List<BasicEventWithSender> events) async { Future<void> _handleToDeviceEvents(List<BasicEventWithSender> events) async {
for (var i = 0; i < events.length; i++) { for (final event in events) {
var toDeviceEvent = ToDeviceEvent.fromJson(events[i].toJson()); var toDeviceEvent = ToDeviceEvent.fromJson(event.toJson());
Logs().v('Got to_device event of type ${toDeviceEvent.type}');
if (toDeviceEvent.type == EventTypes.Encrypted && encryptionEnabled) { if (toDeviceEvent.type == EventTypes.Encrypted && encryptionEnabled) {
toDeviceEvent = await encryption.decryptToDeviceEvent(toDeviceEvent); toDeviceEvent = await encryption.decryptToDeviceEvent(toDeviceEvent);
Logs().v('Decrypted type is: ${toDeviceEvent.type}');
} }
if (encryptionEnabled) { if (encryptionEnabled) {
await encryption.handleToDeviceEvent(toDeviceEvent); await encryption.handleToDeviceEvent(toDeviceEvent);
@ -1603,6 +1605,7 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
bool onlyVerified = false, bool onlyVerified = false,
}) async { }) async {
if (!encryptionEnabled) return; 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 // Don't send this message to blocked devices, and if specified onlyVerified
// then only send it to verified devices // then only send it to verified devices
if (deviceKeys.isNotEmpty) { if (deviceKeys.isNotEmpty) {
@ -1612,6 +1615,8 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
(onlyVerified && !deviceKeys.verified)); (onlyVerified && !deviceKeys.verified));
if (deviceKeys.isEmpty) return; 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 // Send with send-to-device messaging
var data = <String, Map<String, Map<String, dynamic>>>{}; var data = <String, Map<String, Map<String, dynamic>>>{};