mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Fixed duplicate vote check being broken.
This commit is contained in:
parent
a0bbffaf91
commit
db1a3a4062
1 changed files with 6 additions and 6 deletions
12
index.js
12
index.js
|
@ -185,10 +185,10 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
|
|||
let hashedIP = getHash(ip + globalSalt);
|
||||
|
||||
//check if vote has already happened
|
||||
privateDB.prepare("SELECT type FROM votes WHERE userID = ? AND UUID = ?").get(userID, UUID, function(err, row) {
|
||||
privateDB.prepare("SELECT type FROM votes WHERE userID = ? AND UUID = ?").get(userID, UUID, function(err, votesRow) {
|
||||
if (err) console.log(err);
|
||||
|
||||
if (row != undefined && row.type == type) {
|
||||
if (votesRow != undefined && votesRow.type == type) {
|
||||
//they have already done this exact vote
|
||||
res.status(405).send("Duplicate Vote");
|
||||
return;
|
||||
|
@ -209,11 +209,11 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
|
|||
res.sendStatus(400);
|
||||
return;
|
||||
}
|
||||
if (row != undefined) {
|
||||
if (row.type == 1) {
|
||||
if (votesRow != undefined) {
|
||||
if (votesRow.type == 1) {
|
||||
//upvote
|
||||
oldIncrementAmount = 1;
|
||||
} else if (row.type == 0) {
|
||||
} else if (votesRow.type == 0) {
|
||||
//downvote
|
||||
oldIncrementAmount = -1;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
|
|||
}
|
||||
|
||||
//update the votes table
|
||||
if (row != undefined) {
|
||||
if (votesRow != undefined) {
|
||||
privateDB.prepare("UPDATE votes SET type = ? WHERE userID = ? AND UUID = ?").run(type, userID, UUID);
|
||||
} else {
|
||||
privateDB.prepare("INSERT INTO votes VALUES(?, ?, ?, ?)").run(UUID, userID, hashedIP, type);
|
||||
|
|
Loading…
Reference in a new issue