2023-01-16 23:00:10 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
|
|
|
|
2020-03-27 11:35:03 -06:00
|
|
|
// We use these when displaying notifications in the notificationsDrawer
|
|
|
|
|
|
|
|
|
|
// gets all activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationActivities', () => {
|
2023-03-11 19:32:16 +01:00
|
|
|
const ret = activities();
|
|
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all attachments associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationAttachments', function() {
|
2023-03-11 19:32:16 +01:00
|
|
|
const ret = Attachments.find({
|
2020-03-27 11:35:03 -06:00
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.attachmentId)
|
|
|
|
|
.filter(v => !!v),
|
2020-09-16 09:49:51 -05:00
|
|
|
}.cursor,
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all cards associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationCards', function() {
|
2023-03-12 11:25:15 +01:00
|
|
|
const ret = ReactiveCache.getCards(
|
|
|
|
|
{
|
|
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.cardId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
2023-03-12 11:25:15 +01:00
|
|
|
{},
|
|
|
|
|
true,
|
|
|
|
|
);
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all checklistItems associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationChecklistItems', function() {
|
2023-03-12 18:06:39 +01:00
|
|
|
const ret = ReactiveCache.getChecklistItems(
|
|
|
|
|
{
|
|
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.checklistItemId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
2023-03-12 18:06:39 +01:00
|
|
|
{},
|
|
|
|
|
true,
|
|
|
|
|
);
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all checklists associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationChecklists', function() {
|
2023-03-12 18:07:50 +01:00
|
|
|
const ret = ReactiveCache.getChecklists(
|
|
|
|
|
{
|
|
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.checklistId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
2023-03-12 18:07:50 +01:00
|
|
|
{},
|
|
|
|
|
true,
|
|
|
|
|
);
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all comments associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationComments', function() {
|
2023-03-11 19:32:16 +01:00
|
|
|
const ret = CardComments.find({
|
2020-03-27 11:35:03 -06:00
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.commentId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all lists associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationLists', function() {
|
2023-03-12 11:52:31 +01:00
|
|
|
const ret = ReactiveCache.getLists(
|
|
|
|
|
{
|
|
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.listId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
2023-03-12 11:52:31 +01:00
|
|
|
{},
|
|
|
|
|
true,
|
|
|
|
|
);
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all swimlanes associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationSwimlanes', function() {
|
2023-03-12 11:55:40 +01:00
|
|
|
const ret = ReactiveCache.getSwimlanes(
|
|
|
|
|
{
|
|
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.swimlaneId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
2023-03-12 11:55:40 +01:00
|
|
|
{},
|
|
|
|
|
true,
|
|
|
|
|
);
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gets all users associated with activities associated with the current user
|
|
|
|
|
Meteor.publish('notificationUsers', function() {
|
2023-03-12 11:59:23 +01:00
|
|
|
const ret = ReactiveCache.getUsers(
|
|
|
|
|
{
|
|
|
|
|
_id: {
|
|
|
|
|
$in: activities()
|
|
|
|
|
.map(v => v.userId)
|
|
|
|
|
.filter(v => !!v),
|
|
|
|
|
},
|
2020-03-27 11:35:03 -06:00
|
|
|
},
|
2023-03-12 11:59:23 +01:00
|
|
|
{},
|
|
|
|
|
true,
|
|
|
|
|
);
|
2023-03-11 19:32:16 +01:00
|
|
|
return ret;
|
2020-03-27 11:35:03 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function activities() {
|
2023-01-16 23:00:10 +01:00
|
|
|
const activityIds = ReactiveCache.getCurrentUser()?.profile?.notifications?.map(v => v.activity) || [];
|
2023-03-26 09:50:00 +02:00
|
|
|
let ret = [];
|
|
|
|
|
if (activityIds.length > 0) {
|
|
|
|
|
ret = Activities.find({
|
|
|
|
|
_id: { $in: activityIds },
|
|
|
|
|
});
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2020-03-27 11:35:03 -06:00
|
|
|
}
|