Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add fully qualified handle for external results (WPB-6256) #2676

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
),
Expand All @@ -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
}
}
}