mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
35 lines
855 B
JavaScript
35 lines
855 B
JavaScript
![]() |
/**
|
||
|
* Post hooks namespace
|
||
|
*/
|
||
|
|
||
|
// Posts.hooks = {
|
||
|
|
||
|
// classCallbacks: [],
|
||
|
|
||
|
// submitClientCallbacks: [],
|
||
|
// submitMethodCallbacks: [],
|
||
|
// afterSubmitMethodCallbacks: [], // runs on server only in a timeout
|
||
|
|
||
|
// editClientCallbacks: [], // loops over modifier object
|
||
|
// editMethodCallbacks: [], // loops over modifier (i.e. "{$set: {foo: bar}}") object
|
||
|
// afterEditMethodCallbacks: [], // loops over modifier object
|
||
|
|
||
|
// approvedCallbacks: []
|
||
|
|
||
|
// };
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 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: {postCount: 1}});
|
||
|
Telescope.upvoteItem(Posts, post, postAuthor);
|
||
|
return post;
|
||
|
}
|
||
|
Telescope.registerCallback("postSubmitAsync", afterPostSubmitOperations);
|