Vulcan/packages/telescope-posts/lib/callbacks.js
2015-05-10 13:37:42 +09:00

12 lines
401 B
JavaScript

/**
* Increment the user's post count and upvote the post
*/
function afterPostSubmitOperations (post) {
var userId = post.userId,
postAuthor = Meteor.users.findOne(userId);
Meteor.users.update({_id: userId}, {$inc: {"telescope.postCount": 1}});
Telescope.upvoteItem(Posts, post, postAuthor);
return post;
}
Telescope.callbacks.register("postSubmitAsync", afterPostSubmitOperations);