Vulcan/packages/example-forum/lib/server/posts/callbacks/voting.js

21 lines
554 B
JavaScript
Raw Normal View History

2017-09-14 10:05:15 +02:00
/*
Voting callbacks
*/
2017-09-29 09:19:23 +09:00
import { Posts } from '../../../modules/posts/index.js';
2017-09-13 16:11:27 +02:00
import Users from 'meteor/vulcan:users';
import { addCallback } from 'meteor/vulcan:core';
2017-09-30 08:37:15 +09:00
import { performVoteServer } from 'meteor/vulcan:voting';
2017-09-13 16:11:27 +02:00
/**
* @summary Make users upvote their own new posts
*/
function PostsNewUpvoteOwnPost(post) {
var postAuthor = Users.findOne(post.userId);
2017-09-30 08:37:15 +09:00
return {...post, ...performVoteServer({ document: post, voteType: 'upvote', collection: Posts, user: postAuthor })};
2017-09-13 16:11:27 +02:00
}
2017-10-21 12:49:16 +09:00
addCallback('posts.new.after', PostsNewUpvoteOwnPost);