summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNicoP-S <paetni1@gmail.com>2020-04-02 20:43:36 +0200
committerGitHub <noreply@github.com>2020-04-02 20:43:36 +0200
commite47ff25d458a0f7f7e61f9397e1730df21dc5cb7 (patch)
tree5e42af18c820337c1eedf837409bbb056acaa83d /models
parent7fa9603f9d53594227258d76a78af4023dc325b0 (diff)
parent1e0b53eb9bcfa6a2833ee2f268f480ca7d9838d7 (diff)
downloadwekan-e47ff25d458a0f7f7e61f9397e1730df21dc5cb7.tar.gz
wekan-e47ff25d458a0f7f7e61f9397e1730df21dc5cb7.tar.bz2
wekan-e47ff25d458a0f7f7e61f9397e1730df21dc5cb7.zip
Merge pull request #2 from wekan/master
Merge Wekan
Diffstat (limited to 'models')
-rw-r--r--models/attachments.js12
-rw-r--r--models/lists.js6
-rw-r--r--models/users.js33
3 files changed, 42 insertions, 9 deletions
diff --git a/models/attachments.js b/models/attachments.js
index 9b8ec04f..3fe1d745 100644
--- a/models/attachments.js
+++ b/models/attachments.js
@@ -219,6 +219,9 @@ if (Meteor.isServer) {
type: 'card',
activityType: 'addAttachment',
attachmentId: doc._id,
+ // this preserves the name so that notifications can be meaningful after
+ // this file is removed
+ attachmentName: doc.original.name,
boardId: doc.boardId,
cardId: doc.cardId,
listId: doc.listId,
@@ -246,18 +249,15 @@ if (Meteor.isServer) {
type: 'card',
activityType: 'deleteAttachment',
attachmentId: doc._id,
+ // this preserves the name so that notifications can be meaningful after
+ // this file is removed
+ attachmentName: doc.original.name,
boardId: doc.boardId,
cardId: doc.cardId,
listId: doc.listId,
swimlaneId: doc.swimlaneId,
});
});
-
- Attachments.files.after.remove((userId, doc) => {
- Activities.remove({
- attachmentId: doc._id,
- });
- });
}
export default Attachments;
diff --git a/models/lists.js b/models/lists.js
index f06b15b1..b123ab4f 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -369,6 +369,9 @@ if (Meteor.isServer) {
activityType: 'createList',
boardId: doc.boardId,
listId: doc._id,
+ // this preserves the name so that the activity can be useful after the
+ // list is deleted
+ title: doc.title,
});
});
@@ -397,6 +400,9 @@ if (Meteor.isServer) {
activityType: 'archivedList',
listId: doc._id,
boardId: doc.boardId,
+ // this preserves the name so that the activity can be useful after the
+ // list is deleted
+ title: doc.title,
});
}
});
diff --git a/models/users.js b/models/users.js
index d56f14ff..20581e65 100644
--- a/models/users.js
+++ b/models/users.js
@@ -165,7 +165,20 @@ Users.attachSchema(
/**
* enabled notifications for the user
*/
- type: [String],
+ type: [Object],
+ optional: true,
+ },
+ 'profile.notifications.$.activity': {
+ /**
+ * The id of the activity this notification references
+ */
+ type: String,
+ },
+ 'profile.notifications.$.read': {
+ /**
+ * the date on which this notification was read
+ */
+ type: Date,
optional: true,
},
'profile.showCardsCountAt': {
@@ -429,6 +442,20 @@ Users.helpers({
return _.contains(notifications, activityId);
},
+ notifications() {
+ const { notifications = [] } = this.profile || {};
+ for (const index in notifications) {
+ if (!notifications.hasOwnProperty(index)) continue;
+ const notification = notifications[index];
+ // this preserves their db sort order for editing
+ notification.dbIndex = index;
+ notification.activity = Activities.findOne(notification.activity);
+ }
+ // this sorts them newest to oldest to match Trello's behavior
+ notifications.reverse();
+ return notifications;
+ },
+
hasShowDesktopDragHandles() {
const profile = this.profile || {};
return profile.showDesktopDragHandles || false;
@@ -573,7 +600,7 @@ Users.mutations({
addNotification(activityId) {
return {
$addToSet: {
- 'profile.notifications': activityId,
+ 'profile.notifications': { activity: activityId },
},
};
},
@@ -581,7 +608,7 @@ Users.mutations({
removeNotification(activityId) {
return {
$pull: {
- 'profile.notifications': activityId,
+ 'profile.notifications': { activity: activityId },
},
};
},