mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +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:
@@ -208,7 +208,7 @@ export abstract class ApiService {
|
||||
deleteManyCiphersAdmin: (request: CipherBulkDeleteRequest) => Promise<any>;
|
||||
putMoveCiphers: (request: CipherBulkMoveRequest) => Promise<any>;
|
||||
putShareCipher: (id: string, request: CipherShareRequest) => Promise<CipherResponse>;
|
||||
putShareCiphers: (request: CipherBulkShareRequest) => Promise<any>;
|
||||
putShareCiphers: (request: CipherBulkShareRequest) => Promise<CipherResponse[]>;
|
||||
putCipherCollections: (
|
||||
id: string,
|
||||
request: CipherCollectionsRequest,
|
||||
|
||||
@@ -532,8 +532,8 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return new CipherResponse(r);
|
||||
}
|
||||
|
||||
putShareCiphers(request: CipherBulkShareRequest): Promise<any> {
|
||||
return this.send("PUT", "/ciphers/share", request, true, false);
|
||||
async putShareCiphers(request: CipherBulkShareRequest): Promise<CipherResponse[]> {
|
||||
return await this.send("PUT", "/ciphers/share", request, true, true);
|
||||
}
|
||||
|
||||
async putCipherCollections(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user