1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

[PM-22204] - update revision date from server response in shareManyWithServer (#15016)

* update revision date from server response in shareManyWithServer

* return CipherResponse instead of Record
This commit is contained in:
Jordan Aasen
2025-06-02 09:06:03 -07:00
committed by GitHub
parent c215fac818
commit 6bb484dc23
3 changed files with 14 additions and 6 deletions

View File

@@ -836,7 +836,7 @@ export class CipherService implements CipherServiceAbstraction {
organizationId: string,
collectionIds: string[],
userId: UserId,
): Promise<any> {
) {
const promises: Promise<any>[] = [];
const encCiphers: Cipher[] = [];
for (const cipher of ciphers) {
@@ -851,7 +851,16 @@ export class CipherService implements CipherServiceAbstraction {
await Promise.all(promises);
const request = new CipherBulkShareRequest(encCiphers, collectionIds, userId);
try {
await this.apiService.putShareCiphers(request);
const response = await this.apiService.putShareCiphers(request);
const responseMap = new Map(response.map((c) => [c.id, c]));
encCiphers.forEach((cipher) => {
const matchingCipher = responseMap.get(cipher.id);
if (matchingCipher) {
cipher.revisionDate = new Date(matchingCipher.revisionDate);
}
});
await this.upsert(encCiphers.map((c) => c.toCipherData()));
} catch (e) {
for (const cipher of ciphers) {
cipher.organizationId = null;
@@ -859,7 +868,6 @@ export class CipherService implements CipherServiceAbstraction {
}
throw e;
}
await this.upsert(encCiphers.map((c) => c.toCipherData()));
}
saveAttachmentWithServer(