From 08a856645b14c11c62c730e34075addc34520f13 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 5 Apr 2021 15:21:07 -0500 Subject: [PATCH] Add collections to ciphers in export model. (#320) * Add collections to ciphers in export model. This enables immediately setting collections from the CLI on create. The other location this code is used is on import of Bitwarden json data. However, collectionId is explicitly nulled out here to be resolved later at the server level. * Linter fix --- src/models/export/cipher.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/models/export/cipher.ts b/src/models/export/cipher.ts index abb4438b04..07b8b56427 100644 --- a/src/models/export/cipher.ts +++ b/src/models/export/cipher.ts @@ -15,6 +15,7 @@ export class Cipher { static template(): Cipher { const req = new Cipher(); req.organizationId = null; + req.collectionIds = null; req.folderId = null; req.type = CipherType.Login; req.name = 'Item name'; @@ -34,6 +35,10 @@ export class Cipher { if (view.organizationId == null) { view.organizationId = req.organizationId; } + if (view.collectionIds || req.collectionIds) { + const set = new Set((view.collectionIds ?? []).concat(req.collectionIds ?? [])); + view.collectionIds = [...set]; + } view.name = req.name; view.notes = req.notes; view.favorite = req.favorite; @@ -95,6 +100,7 @@ export class Cipher { type: CipherType; folderId: string; organizationId: string; + collectionIds: string[]; name: string; notes: string; favorite: boolean;