BIT-1912: Store collection ids after creation or share. (#1033)

This commit is contained in:
Ramsey Smith 2024-02-19 12:05:57 -07:00 committed by Álison Fernandes
parent c33fc8cf97
commit c262dc03c1
2 changed files with 25 additions and 4 deletions

View file

@ -633,7 +633,12 @@ class VaultRepositoryImpl(
),
)
}
.onSuccess { vaultDiskSource.saveCipher(userId = userId, cipher = it) }
.onSuccess {
vaultDiskSource.saveCipher(
userId = userId,
cipher = it.copy(collectionIds = collectionIds),
)
}
.fold(
onFailure = { CreateCipherResult.Error },
onSuccess = { CreateCipherResult.Success },
@ -797,7 +802,12 @@ class VaultRepositoryImpl(
),
)
}
.onSuccess { vaultDiskSource.saveCipher(userId = userId, cipher = it) }
.onSuccess {
vaultDiskSource.saveCipher(
userId = userId,
cipher = it.copy(collectionIds = collectionIds),
)
}
.fold(
onFailure = { ShareCipherResult.Error },
onSuccess = { ShareCipherResult.Success },

View file

@ -1874,7 +1874,12 @@ class VaultRepositoryTest {
),
)
} returns mockCipher.asSuccess()
coEvery { vaultDiskSource.saveCipher(userId, mockCipher) } just runs
coEvery {
vaultDiskSource.saveCipher(
userId,
mockCipher.copy(collectionIds = listOf("mockId-1")),
)
} just runs
val result = vaultRepository.createCipherInOrganization(
cipherView = mockCipherView,
@ -2842,7 +2847,13 @@ class VaultRepositoryTest {
),
)
} returns createMockCipher(number = 1).asSuccess()
coEvery { vaultDiskSource.saveCipher(userId, createMockCipher(number = 1)) } just runs
coEvery {
vaultDiskSource.saveCipher(
userId,
createMockCipher(number = 1)
.copy(collectionIds = listOf("mockId-1")),
)
} just runs
val result = vaultRepository.shareCipher(
cipherId = "mockId-1",