mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
cipher collection apis
This commit is contained in:
@@ -15,6 +15,7 @@ import { LoginUri } from '../models/domain/loginUri';
|
||||
import { SecureNote } from '../models/domain/secureNote';
|
||||
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
|
||||
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
|
||||
import { CipherResponse } from '../models/response/cipherResponse';
|
||||
@@ -357,7 +358,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
|
||||
async shareWithServer(cipher: Cipher): Promise<any> {
|
||||
const request = new CipherShareRequest(cipher);
|
||||
await this.apiService.shareCipher(cipher.id, request);
|
||||
await this.apiService.putShareCipher(cipher.id, request);
|
||||
const userId = await this.userService.getUserId();
|
||||
await this.upsert(cipher.toCipherData(userId));
|
||||
}
|
||||
@@ -392,7 +393,8 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
|
||||
let response: CipherResponse;
|
||||
try {
|
||||
response = await this.apiService.shareCipherAttachment(cipherId, attachmentView.id, fd, organizationId);
|
||||
response = await this.apiService.postShareCipherAttachment(cipherId, attachmentView.id, fd,
|
||||
organizationId);
|
||||
} catch (e) {
|
||||
throw new Error((e as ErrorResponse).getSingleMessage());
|
||||
}
|
||||
@@ -450,6 +452,14 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
return new Cipher(cData);
|
||||
}
|
||||
|
||||
async saveCollectionsWithServer(cipher: Cipher): Promise<any> {
|
||||
const request = new CipherCollectionsRequest(cipher.collectionIds);
|
||||
const response = await this.apiService.putCipherCollections(cipher.id, request);
|
||||
const userId = await this.userService.getUserId();
|
||||
const data = cipher.toCipherData(userId);
|
||||
await this.upsert(data);
|
||||
}
|
||||
|
||||
async upsert(cipher: CipherData | CipherData[]): Promise<any> {
|
||||
const userId = await this.userService.getUserId();
|
||||
let ciphers = await this.storageService.get<{ [id: string]: CipherData; }>(
|
||||
|
||||
Reference in New Issue
Block a user