From 04061aca9ec1244319d4974a636989bcdc547fca Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Thu, 23 Apr 2015 11:24:59 +0900 Subject: [PATCH] change callback syntax and add return statement --- packages/telescope-comments/lib/comments.js | 8 ++++++-- packages/telescope-notifications/lib/notifications.js | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/telescope-comments/lib/comments.js b/packages/telescope-comments/lib/comments.js index a5780d94e..cec01dc9d 100644 --- a/packages/telescope-comments/lib/comments.js +++ b/packages/telescope-comments/lib/comments.js @@ -123,7 +123,7 @@ Comments.before.update(function (userId, doc, fieldNames, modifier, options) { } }); -commentAfterSubmitMethodCallbacks.push(function (comment) { +function afterCommentOperations (comment) { var userId = comment.userId, commentAuthor = Meteor.users.findOne(userId); @@ -143,7 +143,11 @@ commentAfterSubmitMethodCallbacks.push(function (comment) { // upvote comment Telescope.upvoteItem(Comments, comment, commentAuthor); -}); + return comment; + +}; + +commentAfterSubmitMethodCallbacks.push(afterCommentOperations); // ------------------------------------------------------------------------------------------- // // -------------------------------------- Submit Comment ------------------------------------- // diff --git a/packages/telescope-notifications/lib/notifications.js b/packages/telescope-notifications/lib/notifications.js index f2792860b..751606259 100644 --- a/packages/telescope-notifications/lib/notifications.js +++ b/packages/telescope-notifications/lib/notifications.js @@ -26,7 +26,8 @@ Posts.hooks.approvedCallbacks.push(function (post) { }); // add new comment notification callback on comment submit -commentAfterSubmitMethodCallbacks.push(function (comment) { +function addCommentNotification (comment) { + if(Meteor.isServer && !comment.disableNotifications){ var post = Posts.findOne(comment.postId), @@ -81,7 +82,9 @@ commentAfterSubmitMethodCallbacks.push(function (comment) { return comment; -}); +} + +commentAfterSubmitMethodCallbacks.push(addCommentNotification); var emailNotifications = { propertyName: 'emailNotifications',