Vulcan/packages/example-forum/lib/server/comments/callbacks/voting.js
2017-09-13 16:11:27 +02:00

15 lines
526 B
JavaScript

import Users from 'meteor/vulcan:users';
import { addCallback } from 'meteor/vulcan:core';
import Comments from '../../../modules/comments/index.js';
import { operateOnItem } from 'meteor/vulcan:voting';
/**
* @summary Make users upvote their own new comments
*/
function CommentsNewUpvoteOwnComment(comment) {
var commentAuthor = Users.findOne(comment.userId);
return {...comment, ...operateOnItem(Comments, comment, commentAuthor, 'upvote', false)};
}
addCallback('comments.new.sync', CommentsNewUpvoteOwnComment);