mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 05:13:29 +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>;
|
deleteManyCiphersAdmin: (request: CipherBulkDeleteRequest) => Promise<any>;
|
||||||
putMoveCiphers: (request: CipherBulkMoveRequest) => Promise<any>;
|
putMoveCiphers: (request: CipherBulkMoveRequest) => Promise<any>;
|
||||||
putShareCipher: (id: string, request: CipherShareRequest) => Promise<CipherResponse>;
|
putShareCipher: (id: string, request: CipherShareRequest) => Promise<CipherResponse>;
|
||||||
putShareCiphers: (request: CipherBulkShareRequest) => Promise<any>;
|
putShareCiphers: (request: CipherBulkShareRequest) => Promise<CipherResponse[]>;
|
||||||
putCipherCollections: (
|
putCipherCollections: (
|
||||||
id: string,
|
id: string,
|
||||||
request: CipherCollectionsRequest,
|
request: CipherCollectionsRequest,
|
||||||
|
|||||||
@@ -532,8 +532,8 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
return new CipherResponse(r);
|
return new CipherResponse(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
putShareCiphers(request: CipherBulkShareRequest): Promise<any> {
|
async putShareCiphers(request: CipherBulkShareRequest): Promise<CipherResponse[]> {
|
||||||
return this.send("PUT", "/ciphers/share", request, true, false);
|
return await this.send("PUT", "/ciphers/share", request, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async putCipherCollections(
|
async putCipherCollections(
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
organizationId: string,
|
organizationId: string,
|
||||||
collectionIds: string[],
|
collectionIds: string[],
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
): Promise<any> {
|
) {
|
||||||
const promises: Promise<any>[] = [];
|
const promises: Promise<any>[] = [];
|
||||||
const encCiphers: Cipher[] = [];
|
const encCiphers: Cipher[] = [];
|
||||||
for (const cipher of ciphers) {
|
for (const cipher of ciphers) {
|
||||||
@@ -851,7 +851,16 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
const request = new CipherBulkShareRequest(encCiphers, collectionIds, userId);
|
const request = new CipherBulkShareRequest(encCiphers, collectionIds, userId);
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
for (const cipher of ciphers) {
|
for (const cipher of ciphers) {
|
||||||
cipher.organizationId = null;
|
cipher.organizationId = null;
|
||||||
@@ -859,7 +868,6 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
await this.upsert(encCiphers.map((c) => c.toCipherData()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAttachmentWithServer(
|
saveAttachmentWithServer(
|
||||||
|
|||||||
Reference in New Issue
Block a user