Skip to content

Commit

Permalink
refactor: merge PublicUserMapper with UserMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
typfel committed Oct 16, 2023
1 parent 4d801fc commit e828e72
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 432 deletions.
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

0 comments on commit e828e72

Please sign in to comment.