Made it so that each user can only submit 4 sponsorship segments per video

This commit is contained in:
Ajay Ramachandran
2019-07-11 19:45:55 -04:00
parent 1afd720241
commit 9b812721ad

View File

@@ -83,8 +83,14 @@ app.get('/api/postVideoSponsorTimes', function (req, res) {
//get current time
let timeSubmitted = Date.now();
//check to see if the user has already submitted sponsors for this video
db.prepare("SELECT UUID FROM sponsorTimes WHERE userID = ? and videoID = ?").all([userID, videoID], function(err, rows) {
if (rows.length >= 4) {
//too many sponsors for the same video from the same user
res.sendStatus(429);
} else {
//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) {
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) {
@@ -95,7 +101,9 @@ app.get('/api/postVideoSponsorTimes', function (req, res) {
} else {
res.sendStatus(409);
}
})
});
}
});
});
app.get('/database.db', function (req, res) {