activities.js 636 B

123456789101112131415161718192021222324
  1. // We use activities fields at two different places:
  2. // 1. The board sidebar
  3. // 2. The card activity tab
  4. // We use this publication to paginate for these two publications.
  5. Meteor.publish('activities', (kind, id, limit, hideSystem) => {
  6. check(
  7. kind,
  8. Match.Where(x => {
  9. return ['board', 'card'].indexOf(x) !== -1;
  10. }),
  11. );
  12. check(id, String);
  13. check(limit, Number);
  14. check(hideSystem, Boolean);
  15. const selector = hideSystem
  16. ? { $and: [{ activityType: 'addComment' }, { [`${kind}Id`]: id }] }
  17. : { [`${kind}Id`]: id };
  18. return Activities.find(selector, {
  19. limit,
  20. sort: { createdAt: -1 },
  21. });
  22. });