mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01: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,
|
* @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
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue