From bc48164cb98f00fba68698d0424f86ed7d98138a Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Fri, 10 Oct 2025 11:41:18 -0500 Subject: [PATCH] remove archive date when soft deleting (#16794) --- .../src/vault/services/cipher.service.spec.ts | 22 +++++++++++++++++++ .../src/vault/services/cipher.service.ts | 1 + 2 files changed, 23 insertions(+) diff --git a/libs/common/src/vault/services/cipher.service.spec.ts b/libs/common/src/vault/services/cipher.service.spec.ts index b3cb43dcc93..9b1d8096fc7 100644 --- a/libs/common/src/vault/services/cipher.service.spec.ts +++ b/libs/common/src/vault/services/cipher.service.spec.ts @@ -819,6 +819,28 @@ describe("Cipher Service", () => { }); }); + describe("softDelete", () => { + it("clears archivedDate when soft deleting", async () => { + const cipherId = "cipher-id-1" as CipherId; + const archivedCipher = { + ...cipherData, + id: cipherId, + archivedDate: "2024-01-01T12:00:00.000Z", + } as CipherData; + + const ciphers = { [cipherId]: archivedCipher } as Record; + stateProvider.singleUser.getFake(mockUserId, ENCRYPTED_CIPHERS).nextState(ciphers); + + await cipherService.softDelete(cipherId, mockUserId); + + const result = await firstValueFrom( + stateProvider.singleUser.getFake(mockUserId, ENCRYPTED_CIPHERS).state$, + ); + expect(result[cipherId].archivedDate).toBeNull(); + expect(result[cipherId].deletedDate).toBeDefined(); + }); + }); + describe("replace (no upsert)", () => { // In order to set up initial state we need to manually update the encrypted state // which will result in an emission. All tests will have this baseline emission. diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index ced8f2bb796..f0e2f9f9404 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -1412,6 +1412,7 @@ export class CipherService implements CipherServiceAbstraction { return; } ciphers[cipherId].deletedDate = new Date().toISOString(); + ciphers[cipherId].archivedDate = null; }; if (typeof id === "string") {