A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add attachment support in vault
thecodrr49b379298ea7
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.jsindex ea5a2a2a1..31f5951dc 100644--- a/packages/core/api/vault.js+++ b/packages/core/api/vault.js@@ -203,14 +203,21 @@ export default class Vault {async _lockNote(note, password) {let { id, content: { type, data } = {}, contentId } = note;+ // Case: when note is being newly lockedif (!data || !type || !contentId) {note = this._db.notes.note(id).data;if (note.locked) return;contentId = note.contentId;let content = await this._db.content.raw(contentId, false);- // TODO:- // 1. extract and empty out all attachments from note contents- // 2. encrypt them with vault password+ // NOTE:+ // At this point, the note already has all the attachments extracted+ // so we should just encrypt it as normal.+ data = content.data;+ type = content.type;+ } else {+ const [content] = await this._db.content.extractAttachments([+ { data, type, noteId: id },+ ]);data = content.data;type = content.type;}diff --git a/packages/core/collections/content.js b/packages/core/collections/content.jsindex 55040c18b..813e3780c 100644--- a/packages/core/collections/content.js+++ b/packages/core/collections/content.js@@ -66,6 +66,11 @@ export default class Content extends Collection {return contentItem;}+ /**+ *+ * @param {Array} contents+ * @returns {Promise<Array>}+ */async extractAttachments(contents) {const allAttachments = this._db.attachments.all;for (let contentItem of contents) {