summaryrefslogtreecommitdiffstats
path: root/models/cardComments.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2016-07-18 15:40:41 +0200
committerMaxime Quandalle <maxime@quandalle.com>2016-07-18 15:40:41 +0200
commit4f5cecf738b2bbb9612338737de6172de8874669 (patch)
treec34087b23fe4fcc4d555d0d00775314f18955fb4 /models/cardComments.js
parent855f56c61a39b03442c4962e3afabd80f7fcd721 (diff)
parente521fe617ee923f72d5d6ca27cc03147d353eec4 (diff)
downloadwekan-4f5cecf738b2bbb9612338737de6172de8874669.tar.gz
wekan-4f5cecf738b2bbb9612338737de6172de8874669.tar.bz2
wekan-4f5cecf738b2bbb9612338737de6172de8874669.zip
Merge #616 into devel
Diffstat (limited to 'models/cardComments.js')
-rw-r--r--models/cardComments.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/models/cardComments.js b/models/cardComments.js
index 224deb03..ce6edf3c 100644
--- a/models/cardComments.js
+++ b/models/cardComments.js
@@ -16,10 +16,22 @@ CardComments.attachSchema(new SimpleSchema({
createdAt: {
type: Date,
denyUpdate: false,
+ autoValue() { // eslint-disable-line consistent-return
+ if (this.isInsert) {
+ return new Date();
+ } else {
+ this.unset();
+ }
+ },
},
// XXX Should probably be called `authorId`
userId: {
type: String,
+ autoValue() { // eslint-disable-line consistent-return
+ if (this.isInsert && !this.isSet) {
+ return this.userId;
+ }
+ },
},
}));
@@ -44,11 +56,6 @@ CardComments.helpers({
CardComments.hookOptions.after.update = { fetchPrevious: false };
-CardComments.before.insert((userId, doc) => {
- doc.createdAt = new Date();
- doc.userId = userId;
-});
-
if (Meteor.isServer) {
CardComments.after.insert((userId, doc) => {
Activities.insert({