diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-07-19 21:35:50 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-07-19 21:35:50 +0300 |
commit | 31400673304d39c95ecb04c430aceff2f96e1987 (patch) | |
tree | 6a23e2b02ff2b0e3a1aa931a5a1feaa401f95b14 /models/cardComments.js | |
parent | 57f9c1df69c61fc0d2921f89309df9262935356d (diff) | |
parent | b0dea10a38a96577fcb98d9796fb76a980fa7f69 (diff) | |
download | wekan-31400673304d39c95ecb04c430aceff2f96e1987.tar.gz wekan-31400673304d39c95ecb04c430aceff2f96e1987.tar.bz2 wekan-31400673304d39c95ecb04c430aceff2f96e1987.zip |
Merge branch 'zarnifoulette-devel' into devel
Fix: Activity user messed up when creating a card using the REST-API.
Thanks to zarnifoulette ! Closes #1045
Diffstat (limited to 'models/cardComments.js')
-rw-r--r-- | models/cardComments.js | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/models/cardComments.js b/models/cardComments.js index e51275a4..352030f1 100644 --- a/models/cardComments.js +++ b/models/cardComments.js @@ -56,6 +56,16 @@ CardComments.helpers({ CardComments.hookOptions.after.update = { fetchPrevious: false }; +function commentCreation(userId, doc){ + Activities.insert({ + userId, + activityType: 'addComment', + boardId: doc.boardId, + cardId: doc.cardId, + commentId: doc._id, + }); +} + if (Meteor.isServer) { // Comments are often fetched within a card, so we create an index to make these // queries more efficient. @@ -64,13 +74,7 @@ if (Meteor.isServer) { }); CardComments.after.insert((userId, doc) => { - Activities.insert({ - userId, - activityType: 'addComment', - boardId: doc.boardId, - cardId: doc.cardId, - commentId: doc._id, - }); + commentCreation(userId, doc); }); CardComments.after.remove((userId, doc) => { @@ -114,12 +118,16 @@ if (Meteor.isServer) { Authentication.checkUserId( req.userId); const paramBoardId = req.params.boardId; const paramCardId = req.params.cardId; - const id = CardComments.insert({ + const id = CardComments.direct.insert({ userId: req.body.authorId, text: req.body.comment, cardId: paramCardId, boardId: paramBoardId, }); + + const cardComment = CardComments.findOne({_id: id, cardId:paramCardId, boardId: paramBoardId }); + commentCreation(req.body.authorId, cardComment); + JsonRoutes.sendResult(res, { code: 200, data: { |