1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/helpers/cards/get-actions.js
2022-07-29 17:40:18 +02:00

36 lines
660 B
JavaScript

const LIMIT = 50;
module.exports = {
inputs: {
idOrIds: {
type: 'json',
custom: (value) => _.isString(value) || _.every(value, _.isString),
required: true,
},
beforeId: {
type: 'string',
},
withDetails: {
type: 'boolean',
defaultsTo: false,
},
},
async fn(inputs) {
const criteria = {
cardId: inputs.idOrIds,
};
if (!_.isUndefined(inputs.beforeId)) {
criteria.id = {
'<': inputs.beforeId,
};
}
if (!inputs.withDetails) {
criteria.type = Action.Types.COMMENT_CARD;
}
return sails.helpers.actions.getMany(criteria, LIMIT);
},
};