From 806062c8d1a0e9db8c1f9f36cded6454403944cb Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 8 Sep 2023 00:22:48 +0200 Subject: [PATCH] fix undelete attachments --- src/services/notes.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/services/notes.js b/src/services/notes.js index d026949d9..cae0aff6b 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -15,6 +15,7 @@ const becca = require('../becca/becca'); const BBranch = require('../becca/entities/bbranch'); const BNote = require('../becca/entities/bnote'); const BAttribute = require('../becca/entities/battribute'); +const BAttachment = require("../becca/entities/battachment"); const dayjs = require("dayjs"); const htmlSanitizer = require("./html_sanitizer"); const ValidationError = require("../errors/validation_error"); @@ -810,6 +811,16 @@ function undeleteBranch(branchId, deleteId, taskContext) { new BAttribute(attributeRow).save({skipValidation: true}); } + const attachmentRows = sql.getRows(` + SELECT * FROM attachments + WHERE isDeleted = 1 + AND deleteId = ? + AND ownerId = ?`, [deleteId, noteRow.noteId]); + + for (const attachmentRow of attachmentRows) { + new BAttachment(attachmentRow).save(); + } + const childBranchIds = sql.getColumn(` SELECT branches.branchId FROM branches