Skip to content
Open
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 @@ -18,6 +18,7 @@
package com.wire.kalium.logic.feature.e2ei.usecase

import com.wire.kalium.common.error.CoreFailure
import com.wire.kalium.common.error.StorageFailure
import com.wire.kalium.logic.data.conversation.ClientId
import com.wire.kalium.logic.data.conversation.MLSConversationRepository
import com.wire.kalium.logic.feature.e2ei.MLSClientIdentity
Expand All @@ -38,6 +39,12 @@ public sealed class GetMLSClientIdentityResult {

public sealed class Failure : GetMLSClientIdentityResult() {
public data object IdentityNotFound : Failure()

/**
* E2EI identity cannot be fetched because there is no common MLS conversation
* with the user whose device identity is being queried.
*/
public data object E2EINotAvailable : Failure()
public data class Generic(val coreFailure: CoreFailure) : Failure()
}
}
Expand All @@ -52,7 +59,12 @@ internal class GetMLSClientIdentityUseCaseImpl internal constructor(
mlsConversationRepository.getClientIdentity(mlsContext, clientId)
}
.fold(
{ GetMLSClientIdentityResult.Failure.Generic(it) },
{ failure ->
when (failure) {
is StorageFailure.DataNotFound -> GetMLSClientIdentityResult.Failure.E2EINotAvailable
else -> GetMLSClientIdentityResult.Failure.Generic(failure)
}
},
{ wireIdentity ->
wireIdentity?.let {
GetMLSClientIdentityResult.Success(MLSClientIdentity.fromWireIdentity(it))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class GetE2eiCertificateUseCaseTest {
}

@Test
fun givenRepositoryReturnsStorageFailure_whenRunningUseCase_thenReturnGenericFailure() = runTest {
fun givenRepositoryReturnsStorageDataNotFound_whenRunningUseCase_thenReturnE2EINotAvailable() = runTest {
val (arrangement, getE2eiCertificateUseCase) = Arrangement()
.withRepositoryFailure(StorageFailure.DataNotFound)
.arrange()
Expand All @@ -73,7 +73,7 @@ class GetE2eiCertificateUseCaseTest {
arrangement.mlsConversationRepository.getClientIdentity(any(), any())
}.wasInvoked(once)

assertIs<GetMLSClientIdentityResult.Failure.Generic>(result)
assertIs<GetMLSClientIdentityResult.Failure.E2EINotAvailable>(result)
}

@Test
Expand Down
Loading