mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 20:46:40 -04:00
commit
a94d739849
1 changed files with 27 additions and 27 deletions
10
lib/vote.js
10
lib/vote.js
|
@ -49,7 +49,7 @@
|
||||||
cancelDownvote(collection, item, user);
|
cancelDownvote(collection, item, user);
|
||||||
|
|
||||||
// Votes & Score
|
// Votes & Score
|
||||||
var result = collection.update({_id: item && item._id, upvoters: {$not: {$in: [user._id]}}},{
|
var result = collection.update({_id: item && item._id, upvoters: { $ne: user._id }},{
|
||||||
$addToSet: {upvoters: user._id},
|
$addToSet: {upvoters: user._id},
|
||||||
$inc: {upvotes: 1, baseScore: votePower},
|
$inc: {upvotes: 1, baseScore: votePower},
|
||||||
$set: {inactive: false}
|
$set: {inactive: false}
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
cancelUpvote(collection, item, user);
|
cancelUpvote(collection, item, user);
|
||||||
|
|
||||||
// Votes & Score
|
// Votes & Score
|
||||||
var result = collection.update({_id: item && item._id, downvoters: {$not: {$in: [user._id]}}},{
|
var result = collection.update({_id: item && item._id, downvoters: { $ne: user._id }},{
|
||||||
$addToSet: {downvoters: user._id},
|
$addToSet: {downvoters: user._id},
|
||||||
$inc: {downvotes: 1, baseScore: -votePower},
|
$inc: {downvotes: 1, baseScore: -votePower},
|
||||||
$set: {inactive: false}
|
$set: {inactive: false}
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var cancelUpvote = function (collection, item) {
|
var cancelUpvote = function (collection, item) {
|
||||||
var user = Meteor.user();
|
var user = Meteor.user(),
|
||||||
votePower = getVotePower(user),
|
votePower = getVotePower(user),
|
||||||
collectionName = collection._name.slice(0,1).toUpperCase()+collection._name.slice(1);
|
collectionName = collection._name.slice(0,1).toUpperCase()+collection._name.slice(1);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Votes & Score
|
// Votes & Score
|
||||||
var result = collection.update({_id: item && item._id, upvoters: { $in: [user._id]}},{
|
var result = collection.update({_id: item && item._id, upvoters: user._id},{
|
||||||
$pull: {upvoters: user._id},
|
$pull: {upvoters: user._id},
|
||||||
$inc: {upvotes: -1, baseScore: -votePower},
|
$inc: {upvotes: -1, baseScore: -votePower},
|
||||||
$set: {inactive: false}
|
$set: {inactive: false}
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Votes & Score
|
// Votes & Score
|
||||||
var result = collection.update({_id: item && item._id, downvoters: {$in: [user._id]}},{
|
var result = collection.update({_id: item && item._id, downvoters: user._id},{
|
||||||
$pull: {downvoters: user._id},
|
$pull: {downvoters: user._id},
|
||||||
$inc: {downvotes: 1, baseScore: votePower},
|
$inc: {downvotes: 1, baseScore: votePower},
|
||||||
$set: {inactive: false}
|
$set: {inactive: false}
|
||||||
|
|
Loading…
Add table
Reference in a new issue