2022-07-29 17:40:18 +02:00
|
|
|
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: {
|
2021-06-24 01:05:22 +05:00
|
|
|
idOrIds: {
|
2019-08-31 04:07:25 +05:00
|
|
|
type: 'json',
|
2022-12-26 21:10:50 +01:00
|
|
|
custom: idOrIdsValidator,
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
beforeId: {
|
2019-11-05 18:01:42 +05:00
|
|
|
type: 'string',
|
|
|
|
},
|
2022-07-29 17:40:18 +02:00
|
|
|
withDetails: {
|
|
|
|
type: 'boolean',
|
|
|
|
defaultsTo: false,
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
async fn(inputs) {
|
2019-08-31 04:07:25 +05:00
|
|
|
const criteria = {
|
2021-06-24 01:05:22 +05:00
|
|
|
cardId: inputs.idOrIds,
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!_.isUndefined(inputs.beforeId)) {
|
|
|
|
criteria.id = {
|
2019-11-05 18:01:42 +05:00
|
|
|
'<': inputs.beforeId,
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-29 17:40:18 +02:00
|
|
|
if (!inputs.withDetails) {
|
|
|
|
criteria.type = Action.Types.COMMENT_CARD;
|
|
|
|
}
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
return sails.helpers.actions.getMany(criteria, LIMIT);
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|