1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

save share response

This commit is contained in:
Kyle Spearrin 2018-10-23 16:16:59 -04:00
parent 2f510a7988
commit 43c0cbce45
3 changed files with 7 additions and 5 deletions

View File

@ -141,7 +141,7 @@ export abstract class ApiService {
deleteCipherAdmin: (id: string) => Promise<any>; deleteCipherAdmin: (id: string) => Promise<any>;
deleteManyCiphers: (request: CipherBulkDeleteRequest) => Promise<any>; deleteManyCiphers: (request: CipherBulkDeleteRequest) => Promise<any>;
putMoveCiphers: (request: CipherBulkMoveRequest) => Promise<any>; putMoveCiphers: (request: CipherBulkMoveRequest) => Promise<any>;
putShareCipher: (id: string, request: CipherShareRequest) => Promise<any>; putShareCipher: (id: string, request: CipherShareRequest) => Promise<CipherResponse>;
putShareCiphers: (request: CipherBulkShareRequest) => Promise<any>; putShareCiphers: (request: CipherBulkShareRequest) => Promise<any>;
putCipherCollections: (id: string, request: CipherCollectionsRequest) => Promise<any>; putCipherCollections: (id: string, request: CipherCollectionsRequest) => Promise<any>;
putCipherCollectionsAdmin: (id: string, request: CipherCollectionsRequest) => Promise<any>; putCipherCollectionsAdmin: (id: string, request: CipherCollectionsRequest) => Promise<any>;

View File

@ -374,8 +374,9 @@ export class ApiService implements ApiServiceAbstraction {
return this.send('PUT', '/ciphers/move', request, true, false); return this.send('PUT', '/ciphers/move', request, true, false);
} }
putShareCipher(id: string, request: CipherShareRequest): Promise<any> { async putShareCipher(id: string, request: CipherShareRequest): Promise<CipherResponse> {
return this.send('PUT', '/ciphers/' + id + '/share', request, true, false); const r = await this.send('PUT', '/ciphers/' + id + '/share', request, true, true);
return new CipherResponse(r);
} }
putShareCiphers(request: CipherBulkShareRequest): Promise<any> { putShareCiphers(request: CipherBulkShareRequest): Promise<any> {

View File

@ -465,9 +465,10 @@ export class CipherService implements CipherServiceAbstraction {
cipher.collectionIds = collectionIds; cipher.collectionIds = collectionIds;
const encCipher = await this.encrypt(cipher); const encCipher = await this.encrypt(cipher);
const request = new CipherShareRequest(encCipher); const request = new CipherShareRequest(encCipher);
await this.apiService.putShareCipher(cipher.id, request); const response = await this.apiService.putShareCipher(cipher.id, request);
const userId = await this.userService.getUserId(); const userId = await this.userService.getUserId();
await this.upsert(encCipher.toCipherData(userId)); const data = new CipherData(response, userId, collectionIds);
await this.upsert(data);
} }
async shareManyWithServer(ciphers: CipherView[], organizationId: string, collectionIds: string[]): Promise<any> { async shareManyWithServer(ciphers: CipherView[], organizationId: string, collectionIds: string[]): Promise<any> {