1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 21:29:43 +02:00
planka/server/api/helpers/cards/get-actions.js

39 lines
704 B
JavaScript
Raw Normal View History

const LIMIT = 50;
2019-08-31 04:07:25 +05:00
2022-12-26 21:10:50 +01:00
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
2019-08-31 04:07:25 +05:00
module.exports = {
inputs: {
idOrIds: {
2019-08-31 04:07:25 +05:00
type: 'json',
2022-12-26 21:10:50 +01:00
custom: idOrIdsValidator,
required: true,
2019-08-31 04:07:25 +05:00
},
beforeId: {
type: 'string',
},
withDetails: {
type: 'boolean',
defaultsTo: false,
},
2019-08-31 04:07:25 +05:00
},
async fn(inputs) {
2019-08-31 04:07:25 +05:00
const criteria = {
cardId: inputs.idOrIds,
2019-08-31 04:07:25 +05:00
};
if (!_.isUndefined(inputs.beforeId)) {
criteria.id = {
'<': inputs.beforeId,
2019-08-31 04:07:25 +05:00
};
}
if (!inputs.withDetails) {
criteria.type = Action.Types.COMMENT_CARD;
}
return sails.helpers.actions.getMany(criteria, LIMIT);
},
2019-08-31 04:07:25 +05:00
};