Fix /api/board/{boardId}/attachments

This commit is contained in:
Vid Smole 2023-07-05 11:05:37 +02:00
parent e128a5775d
commit 41664f16a3

View file

@ -2266,27 +2266,33 @@ if (Meteor.isServer) {
* @return_type [{attachmentId: string, * @return_type [{attachmentId: string,
* attachmentName: string, * attachmentName: string,
* attachmentType: string, * attachmentType: string,
* cardId: string, * url: string,
* urlDownload: string,
* boardId: string,
* swimlaneId: string,
* listId: string, * listId: string,
* swimlaneId: string}] * cardId: string
* }]
*/ */
JsonRoutes.add('GET', '/api/boards/:boardId/attachments', function(req, res) { JsonRoutes.add('GET', '/api/boards/:boardId/attachments', function(req, res) {
const paramBoardId = req.params.boardId; const paramBoardId = req.params.boardId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
JsonRoutes.sendResult(res, { JsonRoutes.sendResult(res, {
code: 200, code: 200,
data: Attachments.files data: Attachments
.find({ boardId: paramBoardId }, { fields: { boardId: 0 } }) .find({'meta.boardId': paramBoardId })
.map(function(doc) { .each()
.map(function(attachment) {
return { return {
attachmentId: doc._id, attachmentId: attachment._id,
attachmentName: doc.original.name, attachmentName: attachment.name,
attachmentType: doc.original.type, attachmentType: attachment.type,
url: FlowRouter.url(doc.url()), url: FlowRouter.url(attachment.link()),
urlDownload: `${FlowRouter.url(doc.url())}?download=true&token=`, urlDownload: `${FlowRouter.url(attachment.link())}?download=true&token=`,
cardId: doc.cardId, boardId: attachment.meta.boardId,
listId: doc.listId, swimlaneId: attachment.meta.swimlaneId,
swimlaneId: doc.swimlaneId, listId: attachment.meta.listId,
cardId: attachment.meta.cardId
}; };
}), }),
}); });