diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt index b9662a8a77c..6ce16825226 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt @@ -117,7 +117,17 @@ sealed interface CoreFailure { * No common Protocol found in order to establish a conversation between parties. * Could be, for example, that the desired user only supports Proteus, but we only support MLS. */ - data object NoCommonProtocolFound : FeatureFailure() + sealed class NoCommonProtocolFound : FeatureFailure() { + /** + * SelfClient needs to update to support MLS + */ + data object SelfNeedToUpdate : NoCommonProtocolFound() + + /** + * Other User needs to update to support MLS + */ + data object OtherNeedToUpdate : NoCommonProtocolFound() + } } sealed class NetworkFailure : CoreFailure { diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelector.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelector.kt index d0608b8abdd..64ca6ef2bf8 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelector.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelector.kt @@ -52,7 +52,8 @@ internal class OneOnOneProtocolSelectorImpl( return when { commonProtocols.contains(SupportedProtocol.MLS) -> Either.Right(SupportedProtocol.MLS) commonProtocols.contains(SupportedProtocol.PROTEUS) -> Either.Right(SupportedProtocol.PROTEUS) - else -> Either.Left(CoreFailure.NoCommonProtocolFound) + selfUserProtocols.contains(SupportedProtocol.MLS) -> Either.Left(CoreFailure.NoCommonProtocolFound.OtherNeedToUpdate) + else -> Either.Left(CoreFailure.NoCommonProtocolFound.SelfNeedToUpdate) } } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/GetOrCreateOneToOneConversationUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/GetOrCreateOneToOneConversationUseCaseTest.kt index 377d2712b51..417c56e6672 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/GetOrCreateOneToOneConversationUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/GetOrCreateOneToOneConversationUseCaseTest.kt @@ -69,7 +69,7 @@ class GetOrCreateOneToOneConversationUseCaseTest { val (_, useCase) = arrange { withObserveOneToOneConversationWithOtherUserReturning(Either.Left(StorageFailure.DataNotFound)) withUserByIdReturning(OTHER_USER.right()) - withResolveOneOnOneConversationWithUserReturning(Either.Left(CoreFailure.NoCommonProtocolFound)) + withResolveOneOnOneConversationWithUserReturning(Either.Left(CoreFailure.NoCommonProtocolFound.SelfNeedToUpdate)) } // when diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelectorTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelectorTest.kt index 134e4af7086..50623732ab5 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelectorTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/protocol/OneOnOneProtocolSelectorTest.kt @@ -147,7 +147,22 @@ class OneOnOneProtocolSelectorTest { oneOnOneProtocolSelector.getProtocolForUser(TestUser.USER_ID) .shouldFail { - assertIs(it) + assertIs(it) + } + } + + @Test + fun givenUsersHaveNoProtocolInCommon_thenShouldReturnNoCommonProtocol_2() = runTest { + val failure = StorageFailure.DataNotFound + val (_, oneOnOneProtocolSelector) = arrange { + withSelfUserReturning(TestUser.SELF.copy(supportedProtocols = setOf(SupportedProtocol.PROTEUS))) + withUserByIdReturning(Either.Right(TestUser.OTHER.copy(supportedProtocols = setOf(SupportedProtocol.MLS)))) + withGetDefaultProtocolReturning(failure.left()) + } + + oneOnOneProtocolSelector.getProtocolForUser(TestUser.USER_ID) + .shouldFail { + assertIs(it) } }