From bfda82bb455732ff030839ad2e1efbfc4b7d0900 Mon Sep 17 00:00:00 2001 From: td Date: Tue, 27 Jun 2023 13:30:05 +0530 Subject: [PATCH] chore: fix unexpected null when device is not known --- lib/encryption/utils/key_verification.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/encryption/utils/key_verification.dart b/lib/encryption/utils/key_verification.dart index 5e6fa75f..03f32ffd 100644 --- a/lib/encryption/utils/key_verification.dart +++ b/lib/encryption/utils/key_verification.dart @@ -938,13 +938,14 @@ class KeyVerification { '[Key Verification] Tried to broadcast and un-broadcastable type: $type'); } } else { - if (client.userDeviceKeys[userId]?.deviceKeys[deviceId] == null) { + if (client.userDeviceKeys[userId]?.deviceKeys[deviceId] != null) { + await client.sendToDeviceEncrypted( + [client.userDeviceKeys[userId]!.deviceKeys[deviceId]!], + type, + payload); + } else { Logs().e('[Key Verification] Unknown device'); } - await client.sendToDeviceEncrypted( - [client.userDeviceKeys[userId]!.deviceKeys[deviceId]!], - type, - payload); } } }