fix voting code

This commit is contained in:
Sacha Greif 2015-04-28 10:12:35 +09:00
parent e26fb593ea
commit 3f66f1f10c
2 changed files with 4 additions and 5 deletions

View file

@ -23,7 +23,7 @@ function afterCommentOperations (comment) {
// increment comment count
Meteor.users.update({_id: userId}, {
$inc: {'commentCount': 1}
$inc: {'telescope.commentCount': 1}
});
// update post
@ -37,7 +37,6 @@ function afterCommentOperations (comment) {
Telescope.upvoteItem(Comments, comment, commentAuthor);
return comment;
};
Telescope.callbacks.register("commentSubmitAsync", afterCommentOperations);

View file

@ -4,7 +4,7 @@
// The default is found in base.js in the base package, and returns 1.
var modifyKarma = function (userId, karma) {
Meteor.users.update({_id: userId}, {$inc: {karma: karma}});
Meteor.users.update({_id: userId}, {$inc: {"telescope.karma": karma}});
};
var hasUpvotedItem = function (item, user) {
@ -16,7 +16,7 @@ var hasDownvotedItem = function (item, user) {
};
var addVote = function (userId, vote, collection, upOrDown) {
var field = 'votes.' + upOrDown + 'voted' + collection;
var field = 'telescope.' + upOrDown + 'voted' + collection;
var add = {};
add[field] = vote;
var result = Meteor.users.update({_id: userId}, {
@ -25,7 +25,7 @@ var addVote = function (userId, vote, collection, upOrDown) {
};
var removeVote = function (userId, itemId, collection, upOrDown) {
var field = 'votes.' + upOrDown + 'voted' + collection;
var field = 'telescope.' + upOrDown + 'voted' + collection;
var remove = {};
remove[field] = {itemId: itemId};
Meteor.users.update({_id: userId}, {