mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
edit item collections
This commit is contained in:
@@ -39,6 +39,8 @@ export class EditCommand {
|
||||
switch (object.toLowerCase()) {
|
||||
case 'item':
|
||||
return await this.editCipher(id, req);
|
||||
case 'item-collections':
|
||||
return await this.editCipherCollections(id, req);
|
||||
case 'folder':
|
||||
return await this.editFolder(id, req);
|
||||
default:
|
||||
@@ -66,6 +68,24 @@ export class EditCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private async editCipherCollections(id: string, req: string[]) {
|
||||
const cipher = await this.cipherService.get(id);
|
||||
if (cipher == null) {
|
||||
return Response.notFound();
|
||||
}
|
||||
|
||||
cipher.collectionIds = req;
|
||||
try {
|
||||
await this.cipherService.saveCollectionsWithServer(cipher);
|
||||
const updatedCipher = await this.cipherService.get(cipher.id);
|
||||
const decCipher = await updatedCipher.decrypt();
|
||||
const res = new CipherResponse(decCipher);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private async editFolder(id: string, req: Folder) {
|
||||
const folder = await this.folderService.get(id);
|
||||
if (folder == null) {
|
||||
|
||||
@@ -364,6 +364,9 @@ export class GetCommand {
|
||||
case 'collection':
|
||||
template = Collection.template();
|
||||
break;
|
||||
case 'item-collections':
|
||||
template = ['collection-id1', 'collection-id2'];
|
||||
break;
|
||||
default:
|
||||
return Response.badRequest('Unknown template object.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user