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

refactor: merge PublicUserMapper with UserMapper #2135

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import okio.Path

data class UploadedAssetId(
val key: String,
val domain: String? = null,
val domain: String,
val assetToken: String? = null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.id.IdMapper
import com.wire.kalium.logic.data.id.toDao
import com.wire.kalium.logic.data.id.toModel
import com.wire.kalium.logic.data.publicuser.PublicUserMapper
import com.wire.kalium.logic.data.user.Connection
import com.wire.kalium.logic.data.user.UserMapper
import com.wire.kalium.logic.data.user.type.DomainUserTypeMapper
import com.wire.kalium.logic.data.user.type.UserType
import com.wire.kalium.logic.di.MapperProvider
Expand All @@ -46,7 +46,7 @@ interface ConnectionMapper {
internal class ConnectionMapperImpl(
private val idMapper: IdMapper = MapperProvider.idMapper(),
private val statusMapper: ConnectionStatusMapper = MapperProvider.connectionStatusMapper(),
private val publicUserMapper: PublicUserMapper = MapperProvider.publicUserMapper(),
private val userMapper: UserMapper = MapperProvider.userMapper(),
private val userTypeMapper: DomainUserTypeMapper = MapperProvider.userTypeMapper(),
) : ConnectionMapper {
override fun fromApiToDao(state: ConnectionDTO): ConnectionEntity = ConnectionEntity(
Expand All @@ -68,14 +68,14 @@ internal class ConnectionMapperImpl(
qualifiedToId = qualifiedToId.toModel(),
status = statusMapper.fromDaoModel(status),
toId = toId,
fromUser = otherUser?.let { publicUserMapper.fromUserDetailsEntityToOtherUser(it) }
fromUser = otherUser?.let { userMapper.fromUserDetailsEntityToOtherUser(it) }
)
}

override fun fromDaoToConversationDetails(connection: ConnectionEntity): ConversationDetails = with(connection) {
ConversationDetails.Connection(
conversationId = qualifiedConversationId.toModel(),
otherUser = otherUser?.let { publicUserMapper.fromUserDetailsEntityToOtherUser(it) },
otherUser = otherUser?.let { userMapper.fromUserDetailsEntityToOtherUser(it) },
userType = otherUser?.let { userTypeMapper.fromUserTypeEntity(it.userType) } ?: UserType.GUEST,
lastModifiedDate = lastUpdateDate.toIsoDateTimeString(),
connection = fromDaoToModel(this),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.wire.kalium.logic.data.publicuser.model.UserSearchResult
import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.data.user.UserDataSource
import com.wire.kalium.logic.data.user.UserMapper
import com.wire.kalium.logic.data.user.type.DomainUserTypeMapper
import com.wire.kalium.logic.data.user.type.UserEntityTypeMapper
import com.wire.kalium.logic.di.MapperProvider
import com.wire.kalium.logic.functional.Either
import com.wire.kalium.logic.functional.flatMap
Expand Down Expand Up @@ -92,9 +92,8 @@ internal class SearchUserRepositoryImpl(
private val metadataDAO: MetadataDAO,
private val userDetailsApi: UserDetailsApi,
private val userSearchAPiWrapper: UserSearchApiWrapper,
private val publicUserMapper: PublicUserMapper = MapperProvider.publicUserMapper(),
private val userMapper: UserMapper = MapperProvider.userMapper(),
private val userTypeMapper: DomainUserTypeMapper = MapperProvider.userTypeMapper()
private val userTypeEntityMapper: UserEntityTypeMapper = MapperProvider.userTypeEntityMapper()
) : SearchUserRepository {

override suspend fun searchKnownUsersByNameOrHandleOrEmail(
Expand Down Expand Up @@ -159,16 +158,7 @@ internal class SearchUserRepositoryImpl(
val otherUserList = if (userProfileDTOList.isEmpty()) emptyList() else {
val selfUser = getSelfUser()
userProfileDTOList.map { userProfileDTO ->
publicUserMapper.fromUserProfileDtoToOtherUser(
userDetailResponse = userProfileDTO,
userType = userTypeMapper.fromTeamAndDomain(
otherUserDomain = userProfileDTO.id.domain,
selfUserTeamId = selfUser.teamId?.value,
otherUserTeamId = userProfileDTO.teamId,
selfUserDomain = selfUser.id.domain,
isService = userProfileDTO.service != null,
)
)
userMapper.fromUserProfileDtoToOtherUser(userProfileDTO, selfUser)
}
}
UserSearchResult(otherUserList)
Expand Down Expand Up @@ -202,7 +192,7 @@ internal class SearchUserRepositoryImpl(
}

return listFlow.map {
UserSearchResult(it.map(publicUserMapper::fromUserDetailsEntityToOtherUser))
UserSearchResult(it.map(userMapper::fromUserDetailsEntityToOtherUser))
}
}

Expand Down
Loading
Loading