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

15 lines
573 B
JavaScript
Raw Normal View History

2017-09-13 16:11:27 +02:00
import Users from 'meteor/vulcan:users';
import { addCallback } from 'meteor/vulcan:core';
2017-09-29 09:19:23 +09:00
import { Comments } from '../../../modules/comments/index.js';
2017-09-13 16:11:27 +02:00
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 comments
*/
function CommentsNewUpvoteOwnComment(comment) {
var commentAuthor = Users.findOne(comment.userId);
2017-09-30 08:37:15 +09:00
return {...comment, ...performVoteServer({ document: comment, voteType: 'upvote', collection: Comments, user: commentAuthor })};
2017-09-13 16:11:27 +02:00
}
2017-09-30 08:37:15 +09:00
addCallback('comments.new.async', CommentsNewUpvoteOwnComment);