mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 03:57:06 +03:00
Made it so that each user can only submit 4 sponsorship segments per video
This commit is contained in:
30
index.js
30
index.js
@@ -83,19 +83,27 @@ app.get('/api/postVideoSponsorTimes', function (req, res) {
|
|||||||
//get current time
|
//get current time
|
||||||
let timeSubmitted = Date.now();
|
let timeSubmitted = Date.now();
|
||||||
|
|
||||||
//check if this info has already been submitted first
|
//check to see if the user has already submitted sponsors for this video
|
||||||
db.prepare("SELECT UUID From sponsorTimes WHERE startTime = ? and endTime = ? and videoID = ?").get([startTime, endTime, videoID], function(err, row) {
|
db.prepare("SELECT UUID FROM sponsorTimes WHERE userID = ? and videoID = ?").all([userID, videoID], function(err, rows) {
|
||||||
if (err) console.log(err);
|
if (rows.length >= 4) {
|
||||||
|
//too many sponsors for the same video from the same user
|
||||||
if (row == null) {
|
res.sendStatus(429);
|
||||||
//not a duplicate, execute query
|
|
||||||
db.prepare("INSERT INTO sponsorTimes VALUES(?, ?, ?, ?, ?, ?, ?)").run(videoID, startTime, endTime, UUID, userID, hashedIP, timeSubmitted);
|
|
||||||
|
|
||||||
res.sendStatus(200);
|
|
||||||
} else {
|
} else {
|
||||||
res.sendStatus(409);
|
//check if this info has already been submitted first
|
||||||
|
db.prepare("SELECT UUID FROM sponsorTimes WHERE startTime = ? and endTime = ? and videoID = ?").get([startTime, endTime, videoID], function(err, row) {
|
||||||
|
if (err) console.log(err);
|
||||||
|
|
||||||
|
if (row == null) {
|
||||||
|
//not a duplicate, execute query
|
||||||
|
db.prepare("INSERT INTO sponsorTimes VALUES(?, ?, ?, ?, ?, ?, ?)").run(videoID, startTime, endTime, UUID, userID, hashedIP, timeSubmitted);
|
||||||
|
|
||||||
|
res.sendStatus(200);
|
||||||
|
} else {
|
||||||
|
res.sendStatus(409);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/database.db', function (req, res) {
|
app.get('/database.db', function (req, res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user