From 0f6bace635f79c3ee6ec416afe15759e97153b40 Mon Sep 17 00:00:00 2001 From: AndroidBob Date: Thu, 8 Feb 2024 18:23:38 +0100 Subject: [PATCH] fix: add fully qualified handle for external results (WPB-6256) (#2677) Co-authored-by: Yamil Medina --- .../kotlin/com/wire/android/mapper/ContactMapper.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt index 4162e24aa68..91f41a6fcc2 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt @@ -29,6 +29,7 @@ import com.wire.kalium.logic.data.publicuser.model.UserSearchDetails import com.wire.kalium.logic.data.service.ServiceDetails import com.wire.kalium.logic.data.user.ConnectionState import com.wire.kalium.logic.data.user.OtherUser +import com.wire.kalium.logic.data.user.type.UserType import javax.inject.Inject class ContactMapper @@ -76,7 +77,7 @@ class ContactMapper id = id.value, domain = id.domain, name = name ?: String.EMPTY, - label = handle ?: String.EMPTY, + label = mapUserHandle(user), avatarData = UserAvatarData( asset = previewAssetId?.let { ImageAsset.UserAvatarAsset(wireSessionImageLoader, it) } ), @@ -85,4 +86,14 @@ class ContactMapper ) } } + + /** + * Adds the fully qualified handle to the contact label in case of federated users. + */ + private fun mapUserHandle(user: UserSearchDetails): String { + return when (user.type) { + UserType.FEDERATED -> "${user.handle}@${user.id.domain}" + else -> user.handle ?: String.EMPTY + } + } }