1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 14:53:33 +00:00

Added --trash to delete cmd, added restore cmd

This commit is contained in:
Chad Scharf
2020-04-14 13:04:19 -04:00
parent 6e63a79cfd
commit 49f1fac3ed
8 changed files with 105 additions and 11 deletions

View File

@@ -20,7 +20,7 @@ export class DeleteCommand {
switch (object.toLowerCase()) {
case 'item':
return await this.deleteCipher(id);
return await this.deleteCipher(id, cmd);
case 'attachment':
return await this.deleteAttachment(id, cmd);
case 'folder':
@@ -32,14 +32,18 @@ export class DeleteCommand {
}
}
private async deleteCipher(id: string) {
private async deleteCipher(id: string, cmd: program.Command) {
const cipher = await this.cipherService.get(id);
if (cipher == null) {
return Response.notFound();
}
try {
await this.cipherService.deleteWithServer(id);
if (cmd.trash) {
await this.cipherService.softDeleteWithServer(id);
} else {
await this.cipherService.deleteWithServer(id);
}
return Response.success();
} catch (e) {
return Response.error(e);