From c68db48de9415aa43957fb7d3a74b18355985b60 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 19 Jun 2024 17:41:29 +0200 Subject: [PATCH] Speed up a bit conversation update security level --- .../ui/main/contacts/model/ContactAvatarModel.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt b/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt index 03202c77a..65fb8cd59 100644 --- a/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt +++ b/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt @@ -115,16 +115,17 @@ class ContactAvatarModel @WorkerThread constructor(val friend: Friend, val addre var lowestSecurityLevel = SecurityLevel.EndToEndEncryptedAndVerified for (participant in chatRoom.participants) { - val friend = coreContext.contactsManager.findContactByAddress(participant.address) - if (friend == null || friend.securityLevel == SecurityLevel.None) { + val avatar = coreContext.contactsManager.getContactAvatarModelForAddress( + participant.address + ) + val level = avatar.trust.value ?: SecurityLevel.None + if (level == SecurityLevel.None) { lowestSecurityLevel = SecurityLevel.None - } else if (friend.securityLevel == SecurityLevel.Unsafe) { + } else if (level == SecurityLevel.Unsafe) { lowestSecurityLevel = SecurityLevel.Unsafe break - } else if (friend.securityLevel == SecurityLevel.EndToEndEncrypted || friend.securityLevel == SecurityLevel.PointToPointEncrypted) { - if (lowestSecurityLevel != SecurityLevel.None) { - lowestSecurityLevel = SecurityLevel.EndToEndEncrypted - } + } else if (lowestSecurityLevel != SecurityLevel.None && level != SecurityLevel.EndToEndEncryptedAndVerified) { + lowestSecurityLevel = SecurityLevel.EndToEndEncrypted } } trust.postValue(lowestSecurityLevel)