Adding check to only allow a list of categories

This commit is contained in:
Nanobyte 2020-09-09 16:40:13 +02:00
parent 6fe8dfc188
commit dec0971c14
3 changed files with 12 additions and 1 deletions

View file

@ -19,5 +19,6 @@
"privateDBSchema": "./databases/_private.db.sql",
"mode": "development",
"readOnly": false,
"webhooks": []
"webhooks": [],
"categoryList": ["sponsor", "intro", "outro", "interaction", "selfpromo", "music_offtopic"] // List of supported categories any other category will be rejected
}

View file

@ -195,6 +195,11 @@ module.exports = async function postSkipSegments(req, res) {
return;
}
if (!config.categoryList.includes(segments[i].category)) {
res.status("400").send("Category doesn't exist.");
return;
}
let startTime = parseFloat(segments[i].segment[0]);
let endTime = parseFloat(segments[i].segment[1]);

View file

@ -151,6 +151,11 @@ function categoryVote(UUID, userID, isVIP, category, hashedIP, res) {
return;
}
if (!config.categoryList.includes(category)) {
res.status("400").send("Category doesn't exist.");
return;
}
let timeSubmitted = Date.now();
let voteAmount = isVIP ? 500 : 1;