diff options
author | zago <arnaud.zago@gmail.com> | 2017-07-19 10:27:23 +0200 |
---|---|---|
committer | zago <arnaud.zago@gmail.com> | 2017-07-19 10:27:23 +0200 |
commit | e2ee005a5f8235dbe6a244f236fbbfb429f84230 (patch) | |
tree | 67d8eccf9eb4aaa145b3ddb012d87e1c120c683c /models/cardComments.js | |
parent | cbcf10a02b75b574d027fd9bd13eeec8820b816e (diff) | |
download | wekan-e2ee005a5f8235dbe6a244f236fbbfb429f84230.tar.gz wekan-e2ee005a5f8235dbe6a244f236fbbfb429f84230.tar.bz2 wekan-e2ee005a5f8235dbe6a244f236fbbfb429f84230.zip |
direct hook to bypass the checking step with API request
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: { |