From 41664f16a375f979a6fa93be4d037cf3728b3555 Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Wed, 5 Jul 2023 11:05:37 +0200 Subject: [PATCH] Fix /api/board/{boardId}/attachments --- models/boards.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/models/boards.js b/models/boards.js index 24ed7d3e0..87a297d00 100644 --- a/models/boards.js +++ b/models/boards.js @@ -2266,27 +2266,33 @@ if (Meteor.isServer) { * @return_type [{attachmentId: string, * attachmentName: string, * attachmentType: string, - * cardId: string, + * url: string, + * urlDownload: string, + * boardId: string, + * swimlaneId: string, * listId: string, - * swimlaneId: string}] + * cardId: string + * }] */ JsonRoutes.add('GET', '/api/boards/:boardId/attachments', function(req, res) { const paramBoardId = req.params.boardId; Authentication.checkBoardAccess(req.userId, paramBoardId); JsonRoutes.sendResult(res, { code: 200, - data: Attachments.files - .find({ boardId: paramBoardId }, { fields: { boardId: 0 } }) - .map(function(doc) { + data: Attachments + .find({'meta.boardId': paramBoardId }) + .each() + .map(function(attachment) { return { - attachmentId: doc._id, - attachmentName: doc.original.name, - attachmentType: doc.original.type, - url: FlowRouter.url(doc.url()), - urlDownload: `${FlowRouter.url(doc.url())}?download=true&token=`, - cardId: doc.cardId, - listId: doc.listId, - swimlaneId: doc.swimlaneId, + attachmentId: attachment._id, + attachmentName: attachment.name, + attachmentType: attachment.type, + url: FlowRouter.url(attachment.link()), + urlDownload: `${FlowRouter.url(attachment.link())}?download=true&token=`, + boardId: attachment.meta.boardId, + swimlaneId: attachment.meta.swimlaneId, + listId: attachment.meta.listId, + cardId: attachment.meta.cardId }; }), });