From b03d9ed0d457d1f75ee7d898e1f632a85ca383ef Mon Sep 17 00:00:00 2001 From: boris Date: Tue, 9 Jul 2024 15:40:22 +0300 Subject: [PATCH 1/2] Commit with unresolved merge conflicts --- .../conversation/ConversationGroupRepository.kt | 8 +++++++- .../logic/data/keypackage/KeyPackageRepository.kt | 9 +++------ .../data/keypackage/KeyPackageRepositoryTest.kt | 14 ++++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt index 0cb58e990fa..10f21658a5d 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt @@ -131,6 +131,7 @@ internal class ConversationGroupRepositoryImpl( } when (apiResult) { +<<<<<<< HEAD is Either.Left -> handleCreateConverstionFailure( apiResult = apiResult, usersList = usersList, @@ -140,6 +141,11 @@ internal class ConversationGroupRepositoryImpl( ) is Either.Right -> handleGroupConversationCreated(apiResult.value, selfTeamId, usersList, lastUsersAttempt) +======= + is Either.Left -> handleCreateConversationFailure(apiResult, usersList, failedUsersList, name, options) + + is Either.Right -> handleCreateConversationSuccess(apiResult, usersList, failedUsersList, selfTeamId) +>>>>>>> 478ed1e7d8 (fix: Allow creating empty MLS GroupConversation (#2869)) } } @@ -204,7 +210,7 @@ internal class ConversationGroupRepositoryImpl( } } - private suspend fun handleCreateConverstionFailure( + private suspend fun handleCreateConversationFailure( apiResult: Either.Left, usersList: List, name: String?, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepository.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepository.kt index eefe69da366..56ad144486c 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepository.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepository.kt @@ -30,6 +30,7 @@ import com.wire.kalium.logic.data.user.UserId import com.wire.kalium.logic.functional.Either import com.wire.kalium.logic.functional.flatMap import com.wire.kalium.logic.functional.fold +import com.wire.kalium.logic.functional.map import com.wire.kalium.logic.wrapApiRequest import com.wire.kalium.logic.wrapMLSRequest import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageApi @@ -78,7 +79,7 @@ class KeyPackageDataSource( userIds: List, cipherSuite: CipherSuite ): Either = - currentClientIdProvider().flatMap { selfClientId -> + currentClientIdProvider().map { selfClientId -> val failedUsers = mutableSetOf() val claimedKeyPackages = mutableListOf() userIds.forEach { userId -> @@ -99,11 +100,7 @@ class KeyPackageDataSource( } } - if (claimedKeyPackages.isEmpty() && failedUsers.isNotEmpty()) { - Either.Left(CoreFailure.MissingKeyPackages(failedUsers)) - } else { - Either.Right(KeyPackageClaimResult(claimedKeyPackages, failedUsers)) - } + KeyPackageClaimResult(claimedKeyPackages, failedUsers) } override suspend fun uploadNewKeyPackages(clientId: ClientId, amount: Int): Either = diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepositoryTest.kt index 6aae5ccd319..a2c139178d7 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/keypackage/KeyPackageRepositoryTest.kt @@ -121,7 +121,7 @@ class KeyPackageRepositoryTest { } @Test - fun givenAllUsersHaveNoKeyPackagesAvailable_whenClaimingKeyPackagesFromMultipleUsers_thenSuccessFailWithMissingKeyPackages() = runTest { + fun givenAllUsersHaveNoKeyPackagesAvailable_whenClaimingKeyPackagesFromMultipleUsers_thenSuccessWitheEmptySuccessKeyPackages() = runTest { val usersWithout = setOf( Arrangement.USER_ID.copy(value = "missingKP"), Arrangement.USER_ID.copy(value = "alsoMissingKP"), @@ -136,13 +136,14 @@ class KeyPackageRepositoryTest { val result = keyPackageRepository.claimKeyPackages(usersWithout.toList(), CIPHER_SUITE) - result.shouldFail { failure -> - assertIs(failure) + result.shouldSucceed { keyPackages -> + assertEquals(emptyList(), keyPackages.successfullyFetchedKeyPackages) + assertEquals(usersWithout, keyPackages.usersWithoutKeyPackagesAvailable) } } @Test - fun givenUserWithNoKeyPackages_whenClaimingKeyPackagesFromSingleUser_thenResultShouldFailWithError() = runTest { + fun givenUserWithNoKeyPackages_whenClaimingKeyPackagesFromSingleUser_thenSuccessWitheEmptySuccessKeyPackages() = runTest { val (_, keyPackageRepository) = Arrangement() .withCurrentClientId() @@ -151,8 +152,9 @@ class KeyPackageRepositoryTest { val result = keyPackageRepository.claimKeyPackages(listOf(Arrangement.USER_ID), CIPHER_SUITE) - result.shouldFail { failure -> - assertEquals(CoreFailure.MissingKeyPackages(setOf(Arrangement.USER_ID)), failure) + result.shouldSucceed { keyPackages -> + assertEquals(emptyList(), keyPackages.successfullyFetchedKeyPackages) + assertEquals(setOf(Arrangement.USER_ID), keyPackages.usersWithoutKeyPackagesAvailable) } } From cf8a740a85e0e9733a91b8c0b05467e0b43ec3e3 Mon Sep 17 00:00:00 2001 From: Boris Safonov Date: Tue, 9 Jul 2024 16:25:45 +0300 Subject: [PATCH 2/2] Fixed cherry-pick issues --- .../data/conversation/ConversationGroupRepository.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt index 10f21658a5d..7c7129f32da 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationGroupRepository.kt @@ -131,8 +131,7 @@ internal class ConversationGroupRepositoryImpl( } when (apiResult) { -<<<<<<< HEAD - is Either.Left -> handleCreateConverstionFailure( + is Either.Left -> handleCreateConversationFailure( apiResult = apiResult, usersList = usersList, name = name, @@ -141,11 +140,6 @@ internal class ConversationGroupRepositoryImpl( ) is Either.Right -> handleGroupConversationCreated(apiResult.value, selfTeamId, usersList, lastUsersAttempt) -======= - is Either.Left -> handleCreateConversationFailure(apiResult, usersList, failedUsersList, name, options) - - is Either.Right -> handleCreateConversationSuccess(apiResult, usersList, failedUsersList, selfTeamId) ->>>>>>> 478ed1e7d8 (fix: Allow creating empty MLS GroupConversation (#2869)) } }