mirror of
https://github.com/wekan/wekan.git
synced 2025-04-20 12:07:11 -04:00
Fix /api/board/{boardId}/attachments
This commit is contained in:
parent
e128a5775d
commit
41664f16a3
1 changed files with 19 additions and 13 deletions
|
@ -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
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue