Added VIP support to category vote

This commit is contained in:
Ajay Ramachandran
2020-04-29 21:30:07 -04:00
parent f23ead56ad
commit ad169fd6e7

View File

@@ -23,6 +23,8 @@ function categoryVote(UUID, userID, isVIP, category, hashedIP, res) {
let timeSubmitted = Date.now(); let timeSubmitted = Date.now();
let voteAmount = isVIP ? 500 : 1;
// Add the vote // Add the vote
if (db.prepare("select count(*) as count from categoryVotes where UUID = ? and category = ?").get(UUID, category).count > 0) { if (db.prepare("select count(*) as count from categoryVotes where UUID = ? and category = ?").get(UUID, category).count > 0) {
// Update the already existing db entry // Update the already existing db entry
@@ -52,7 +54,8 @@ function categoryVote(UUID, userID, isVIP, category, hashedIP, res) {
let nextCategoryCount = (previousVoteInfo.votes || 0) + 1; let nextCategoryCount = (previousVoteInfo.votes || 0) + 1;
//TODO: In the future, raise this number from zero to make it harder to change categories //TODO: In the future, raise this number from zero to make it harder to change categories
if (nextCategoryCount - currentCategoryCount >= 0) { // VIPs change it every time
if (nextCategoryCount - currentCategoryCount >= 0 || isVIP) {
// Replace the category // Replace the category
db.prepare("update sponsorTimes set category = ? where UUID = ?").run(category, UUID); db.prepare("update sponsorTimes set category = ? where UUID = ?").run(category, UUID);
} }