Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: auto extraction of embedded images not working

thecodrr6aebe50ef375
diff --git a/packages/core/collections/attachments.js b/packages/core/collections/attachments.js
index d5b6d8c17..375204e16 100644
--- a/packages/core/collections/attachments.js
+++ b/packages/core/collections/attachments.js
@@ -174,8 +174,9 @@ export default class Attachments extends Collection {
}
async save(data, type) {
- const key = await this.decryptKey(attachment.key);
- return await this._db.fs.writeEncrypted(null, data, type, key);
+ const key = await this._db.attachments.generateKey();
+ const metadata = await this._db.fs.writeEncrypted(null, data, type, key);
+ return { key, metadata };
}
async downloadImages(noteId) {
diff --git a/packages/core/collections/content.js b/packages/core/collections/content.js
index 490d8f760..382e5b2ec 100644
--- a/packages/core/collections/content.js
+++ b/packages/core/collections/content.js
@@ -6,8 +6,10 @@ import { hasItem } from "../utils/array";
export default class Content extends Collection {
async add(content) {
if (!content) return;
- if (content.deleted || content.migrated)
- return await this._collection.addItem(content);
+ if (content.remote || content.deleted || content.migrated)
+ return await this._collection.addItem(
+ await this.extractAttachments(content)
+ );
const oldContent = await this.raw(content.id, false);
if (content.id && oldContent) {
diff --git a/packages/core/content-types/tiny.js b/packages/core/content-types/tiny.js
index b610115a6..acda87df3 100644
--- a/packages/core/content-types/tiny.js
+++ b/packages/core/content-types/tiny.js
@@ -101,13 +101,15 @@ class Tiny {
const type =
getDatasetAttribute(attachment, "mime") || mime || "image/jpeg";
- const metadata = await store(data, "base64");
+ const { key, metadata } = await store(noteId, data, "base64");
setDatasetAttribute(attachment, "hash", metadata.hash);
attachments.push({
type,
- filename: getDatasetAttribute(attachment, "filename"),
+ filename:
+ getDatasetAttribute(attachment, "filename") || metadata.hash,
...metadata,
+ key,
});
} else {
attachments.push({