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) #2677

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.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 @@
id = id.value,
domain = id.domain,
name = name ?: String.EMPTY,
label = handle ?: String.EMPTY,
label = mapUserHandle(user),

Check warning on line 80 in app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt#L80

Added line #L80 was not covered by tests
avatarData = UserAvatarData(
asset = previewAssetId?.let { ImageAsset.UserAvatarAsset(wireSessionImageLoader, it) }
),
Expand All @@ -85,4 +86,14 @@
)
}
}

/**
* Adds the fully qualified handle to the contact label in case of federated users.
*/
private fun mapUserHandle(user: UserSearchDetails): String {
return when (user.type) {

Check warning on line 94 in app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/mapper/ContactMapper.kt#L94

Added line #L94 was not covered by tests
UserType.FEDERATED -> "${user.handle}@${user.id.domain}"
else -> user.handle ?: String.EMPTY
}
}
}
Loading