mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
bulk move/delete apis
This commit is contained in:
@@ -15,8 +15,11 @@ import { LoginUri } from '../models/domain/loginUri';
|
||||
import { SecureNote } from '../models/domain/secureNote';
|
||||
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
|
||||
|
||||
import { CipherBulkDeleteRequest } from '../models/request/cipherBulkDeleteRequest';
|
||||
import { CipherBulkMoveRequest } from '../models/request/cipherBulkMoveRequest';
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
|
||||
import { CipherResponse } from '../models/response/cipherResponse';
|
||||
import { ErrorResponse } from '../models/response/errorResponse';
|
||||
@@ -41,7 +44,6 @@ import { StorageService } from '../abstractions/storage.service';
|
||||
import { UserService } from '../abstractions/user.service';
|
||||
|
||||
import { Utils } from '../misc/utils';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
|
||||
const Keys = {
|
||||
ciphersPrefix: 'ciphers_',
|
||||
@@ -492,6 +494,26 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
this.decryptedCipherCache = null;
|
||||
}
|
||||
|
||||
async moveManyWithServer(ids: string[], folderId: string): Promise<any> {
|
||||
await this.apiService.putMoveCiphers(new CipherBulkMoveRequest(ids, folderId));
|
||||
|
||||
const userId = await this.userService.getUserId();
|
||||
let ciphers = await this.storageService.get<{ [id: string]: CipherData; }>(
|
||||
Keys.ciphersPrefix + userId);
|
||||
if (ciphers == null) {
|
||||
ciphers = {};
|
||||
}
|
||||
|
||||
ids.forEach((id) => {
|
||||
if (ciphers.hasOwnProperty(id)) {
|
||||
ciphers[id].folderId = folderId;
|
||||
}
|
||||
});
|
||||
|
||||
await this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
|
||||
this.decryptedCipherCache = null;
|
||||
}
|
||||
|
||||
async delete(id: string | string[]): Promise<any> {
|
||||
const userId = await this.userService.getUserId();
|
||||
const ciphers = await this.storageService.get<{ [id: string]: CipherData; }>(
|
||||
@@ -518,6 +540,11 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
await this.delete(id);
|
||||
}
|
||||
|
||||
async deleteManyWithServer(ids: string[]): Promise<any> {
|
||||
await this.apiService.deleteManyCiphers(new CipherBulkDeleteRequest(ids));
|
||||
await this.delete(ids);
|
||||
}
|
||||
|
||||
async deleteAttachment(id: string, attachmentId: string): Promise<void> {
|
||||
const userId = await this.userService.getUserId();
|
||||
const ciphers = await this.storageService.get<{ [id: string]: CipherData; }>(
|
||||
|
||||
Reference in New Issue
Block a user