diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-06-27 15:27:14 -0400 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2019-06-27 15:27:14 -0400 |
commit | a0a482aa8efb3255a523de4524c8e09453d5571f (patch) | |
tree | ef64c00f146add91a484f7f6b27a40a785f459a0 /models/activities.js | |
parent | fb728baf0c87bae5fa39d92089b667ff1ed69fa6 (diff) | |
parent | 3d63b6006b13942a887bbeddebb055d697451223 (diff) | |
download | wekan-a0a482aa8efb3255a523de4524c8e09453d5571f.tar.gz wekan-a0a482aa8efb3255a523de4524c8e09453d5571f.tar.bz2 wekan-a0a482aa8efb3255a523de4524c8e09453d5571f.zip |
Merge branch 'justinr1234-created-modified' into meteor-1.8
Diffstat (limited to 'models/activities.js')
-rw-r--r-- | models/activities.js | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/models/activities.js b/models/activities.js index 908d4b14..0e158802 100644 --- a/models/activities.js +++ b/models/activities.js @@ -69,7 +69,11 @@ Activities.before.insert((userId, doc) => { Activities.after.insert((userId, doc) => { const activity = Activities._transform(doc); RulesHelper.executeRules(activity); +}); +Activities.before.update((userId, doc, fieldNames, modifier, options) => { + modifier.$set = modifier.$set || {}; + modifier.$set.modifiedAt = Date.now(); }); if (Meteor.isServer) { @@ -78,11 +82,21 @@ if (Meteor.isServer) { // are largely used in the App. See #524. Meteor.startup(() => { Activities._collection._ensureIndex({ createdAt: -1 }); + Activities._collection._ensureIndex({ modifiedAt: -1 }); Activities._collection._ensureIndex({ cardId: 1, createdAt: -1 }); Activities._collection._ensureIndex({ boardId: 1, createdAt: -1 }); - Activities._collection._ensureIndex({ commentId: 1 }, { partialFilterExpression: { commentId: { $exists: true } } }); - Activities._collection._ensureIndex({ attachmentId: 1 }, { partialFilterExpression: { attachmentId: { $exists: true } } }); - Activities._collection._ensureIndex({ customFieldId: 1 }, { partialFilterExpression: { customFieldId: { $exists: true } } }); + Activities._collection._ensureIndex( + { commentId: 1 }, + { partialFilterExpression: { commentId: { $exists: true } } } + ); + Activities._collection._ensureIndex( + { attachmentId: 1 }, + { partialFilterExpression: { attachmentId: { $exists: true } } } + ); + Activities._collection._ensureIndex( + { customFieldId: 1 }, + { partialFilterExpression: { customFieldId: { $exists: true } } } + ); // Label activity did not work yet, unable to edit labels when tried this. //Activities._collection._dropIndex({ labelId: 1 }, { "indexKey": -1 }); //Activities._collection._dropIndex({ labelId: 1 }, { partialFilterExpression: { labelId: { $exists: true } } }); @@ -189,18 +203,35 @@ if (Meteor.isServer) { // params.labelId = activity.labelId; //} if (board) { - const watchingUsers = _.pluck(_.where(board.watchers, {level: 'watching'}), 'userId'); - const trackingUsers = _.pluck(_.where(board.watchers, {level: 'tracking'}), 'userId'); - watchers = _.union(watchers, watchingUsers, _.intersection(participants, trackingUsers)); + const watchingUsers = _.pluck( + _.where(board.watchers, { level: 'watching' }), + 'userId' + ); + const trackingUsers = _.pluck( + _.where(board.watchers, { level: 'tracking' }), + 'userId' + ); + watchers = _.union( + watchers, + watchingUsers, + _.intersection(participants, trackingUsers) + ); } Notifications.getUsers(watchers).forEach((user) => { Notifications.notify(user, title, description, params); }); - const integrations = Integrations.find({ boardId: board._id, type: 'outgoing-webhooks', enabled: true, activities: { '$in': [description, 'all'] } }).fetch(); + const integrations = Integrations.find({ + boardId: board._id, + type: 'outgoing-webhooks', + enabled: true, + activities: { $in: [description, 'all'] }, + }).fetch(); if (integrations.length > 0) { Meteor.call('outgoingWebhooks', integrations, description, params); } }); } + +export default Activities; |