diff --git a/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt b/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt index 588cd678401..fd448bbddb8 100644 --- a/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt +++ b/cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/IDs.kt @@ -72,7 +72,7 @@ data class CryptoQualifiedClientId( data class WireIdentity( val clientId: CryptoQualifiedClientId, - val handle: String, + val handle: String, // handle format is "{scheme}%40{handle}@{domain}", example: "wireapp://%40hans.wurst@elna.wire.link" val displayName: String, val domain: String, val certificate: String, @@ -80,7 +80,10 @@ data class WireIdentity( val thumbprint: String, val serialNumber: String, val endTimestamp: Long -) +) { + val handleWithoutSchemeAtSignAndDomain: String + get() = handle.substringAfter("://%40").removeSuffix("@$domain") +} enum class CryptoCertificateStatus { VALID, EXPIRED, REVOKED; diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/MLSConversationsVerificationStatusesHandler.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/MLSConversationsVerificationStatusesHandler.kt index d74f6a7f37d..9a2628352ba 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/MLSConversationsVerificationStatusesHandler.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/MLSConversationsVerificationStatusesHandler.kt @@ -124,7 +124,7 @@ internal class MLSConversationsVerificationStatusesHandlerImpl( val isUserVerified = wireIdentity.firstOrNull { it.status != CryptoCertificateStatus.VALID || it.displayName != persistedMemberInfo?.name || - it.handle != persistedMemberInfo.handle + it.handleWithoutSchemeAtSignAndDomain != persistedMemberInfo.handle } == null if (!isUserVerified) { newStatus = VerificationStatus.NOT_VERIFIED diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt index 70bf507e44b..8c25692f58a 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepositoryTest.kt @@ -1536,6 +1536,50 @@ class MLSConversationRepositoryTest { .wasInvoked(once) } + @Test + fun givenHandleWithSchemeAndDomain_whenGetUserIdentity_thenHandleWithoutSchemeAtSignAndDomainShouldReturnProperValue() = runTest { + // given + val handleWithSchemeAndDomain = "wireapp://%40handle@domain.com" + val handle = "handle" + val groupId = Arrangement.GROUP_ID.value + val (_, mlsConversationRepository) = Arrangement() + .withGetEstablishedSelfMLSGroupIdReturns(groupId) + .withGetMLSClientSuccessful() + .withGetUserIdentitiesReturn(mapOf(groupId to listOf(WIRE_IDENTITY.copy(handle = handleWithSchemeAndDomain)))) + .arrange() + // when + val result = mlsConversationRepository.getUserIdentity(TestUser.USER_ID) + // then + result.shouldSucceed() { + it.forEach { + assertEquals(handle, it.handleWithoutSchemeAtSignAndDomain) + } + } + } + + @Test + fun givenHandleWithSchemeAndDomain_whenGetMemberIdentities_thenHandleWithoutSchemeAtSignAndDomainShouldReturnProperValue() = runTest { + // given + val handleWithSchemeAndDomain = "wireapp://%40handle@domain.com" + val handle = "handle" + val groupId = Arrangement.GROUP_ID.value + val (_, mlsConversationRepository) = Arrangement() + .withGetMLSGroupIdByConversationIdReturns(groupId) + .withGetMLSClientSuccessful() + .withGetUserIdentitiesReturn(mapOf(groupId to listOf(WIRE_IDENTITY.copy(handle = handleWithSchemeAndDomain)))) + .arrange() + // when + val result = mlsConversationRepository.getMembersIdentities(TestConversation.ID, listOf(TestUser.USER_ID)) + // then + result.shouldSucceed() { + it.values.forEach { + it.forEach { + assertEquals(handle, it.handleWithoutSchemeAtSignAndDomain) + } + } + } + } + private class Arrangement { @Mock