summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJonathan Baird <jonathan@smithbox.com>2020-03-27 11:35:03 -0600
committerJonathan Baird <jonathan@smithbox.com>2020-03-27 11:35:03 -0600
commit9819c9f801128d07374b0703b482bdb83a672297 (patch)
treea132421f72031a26b346a96fd9a4615b2bca70c9 /server
parent29d62440a5cf82b01de8183a384c6d7811abad81 (diff)
downloadwekan-9819c9f801128d07374b0703b482bdb83a672297.tar.gz
wekan-9819c9f801128d07374b0703b482bdb83a672297.tar.bz2
wekan-9819c9f801128d07374b0703b482bdb83a672297.zip
add a notification drawer like trello
Diffstat (limited to 'server')
-rw-r--r--server/notifications/profile.js10
-rw-r--r--server/publications/notifications.js100
2 files changed, 103 insertions, 7 deletions
diff --git a/server/notifications/profile.js b/server/notifications/profile.js
index 6d9c7018..608931cf 100644
--- a/server/notifications/profile.js
+++ b/server/notifications/profile.js
@@ -1,9 +1,5 @@
Meteor.startup(() => {
- // XXX: add activity id to profile.notifications,
- // it can be displayed and rendered on web or mobile UI
- // will uncomment the following code once UI implemented
- //
- // Notifications.subscribe('profile', (user, title, description, params) => {
- // user.addNotification(params.activityId);
- // });
+ Notifications.subscribe('profile', (user, title, description, params) => {
+ user.addNotification(params.activityId);
+ });
});
diff --git a/server/publications/notifications.js b/server/publications/notifications.js
new file mode 100644
index 00000000..8cb44f95
--- /dev/null
+++ b/server/publications/notifications.js
@@ -0,0 +1,100 @@
+// We use these when displaying notifications in the notificationsDrawer
+
+// gets all activities associated with the current user
+Meteor.publish('notificationActivities', () => {
+ return activities();
+});
+
+// gets all attachments associated with activities associated with the current user
+Meteor.publish('notificationAttachments', function() {
+ return Attachments.find({
+ _id: {
+ $in: activities()
+ .map(v => v.attachmentId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all cards associated with activities associated with the current user
+Meteor.publish('notificationCards', function() {
+ return Cards.find({
+ _id: {
+ $in: activities()
+ .map(v => v.cardId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all checklistItems associated with activities associated with the current user
+Meteor.publish('notificationChecklistItems', function() {
+ return ChecklistItems.find({
+ _id: {
+ $in: activities()
+ .map(v => v.checklistItemId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all checklists associated with activities associated with the current user
+Meteor.publish('notificationChecklists', function() {
+ return Checklists.find({
+ _id: {
+ $in: activities()
+ .map(v => v.checklistId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all comments associated with activities associated with the current user
+Meteor.publish('notificationComments', function() {
+ return CardComments.find({
+ _id: {
+ $in: activities()
+ .map(v => v.commentId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all lists associated with activities associated with the current user
+Meteor.publish('notificationLists', function() {
+ return Lists.find({
+ _id: {
+ $in: activities()
+ .map(v => v.listId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all swimlanes associated with activities associated with the current user
+Meteor.publish('notificationSwimlanes', function() {
+ return Swimlanes.find({
+ _id: {
+ $in: activities()
+ .map(v => v.swimlaneId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+// gets all users associated with activities associated with the current user
+Meteor.publish('notificationUsers', function() {
+ return Users.find({
+ _id: {
+ $in: activities()
+ .map(v => v.userId)
+ .filter(v => !!v),
+ },
+ });
+});
+
+function activities() {
+ return Activities.find({
+ _id: { $in: Meteor.user().profile.notifications.map(v => v.activity) },
+ });
+}