1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00
planka/server/api/helpers/get-attachment-to-project-path.js
2020-04-21 05:44:12 +05:00

34 lines
590 B
JavaScript
Executable file

module.exports = {
inputs: {
criteria: {
type: 'json',
required: true,
},
},
exits: {
pathNotFound: {},
},
async fn(inputs, exits) {
const attachment = await Attachment.findOne(inputs.criteria);
if (!attachment) {
throw 'pathNotFound';
}
const path = await sails.helpers
.getCardToProjectPath(attachment.cardId)
.intercept('pathNotFound', (nodes) => ({
pathNotFound: {
attachment,
...nodes,
},
}));
return exits.success({
attachment,
...path,
});
},
};