fix undelete attachments

This commit is contained in:
zadam 2023-09-08 00:22:48 +02:00
parent 83f19c0537
commit 806062c8d1

View File

@ -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