attachments WIP

This commit is contained in:
zadam
2023-05-29 00:19:54 +02:00
parent c2f70031d0
commit 0aa119af2c
37 changed files with 448 additions and 320 deletions

View File

@@ -19,6 +19,14 @@ function getAttachment(req) {
return becca.getAttachmentOrThrow(attachmentId, {includeContentLength: true});
}
function getAllAttachments(req) {
const {attachmentId} = req.params;
// one particular attachment is requested, but return all note's attachments
const attachment = becca.getAttachmentOrThrow(attachmentId);
return attachment.getNote()?.getAttachments({includeContentLength: true}) || [];
}
function saveAttachment(req) {
const {noteId} = req.params;
const {attachmentId, role, mime, title, content} = req.body;
@@ -48,6 +56,7 @@ module.exports = {
getAttachmentBlob,
getAttachments,
getAttachment,
getAllAttachments,
saveAttachment,
deleteAttachment,
convertAttachmentToNote