mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-12 18:04:29 +01:00
Merge pull request #178 from FoseFx/fosefx-errorh
Improve missing fields checks (POST skipSegment)
This commit is contained in:
commit
c462323dd5
1 changed files with 16 additions and 5 deletions
|
@ -257,11 +257,22 @@ module.exports = async function postSkipSegments(req, res) {
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if all correct inputs are here and the length is 1 second or more
|
const invalidFields = [];
|
||||||
if (videoID == undefined || userID == undefined || segments == undefined || segments.length < 1) {
|
if (typeof videoID !== 'string') {
|
||||||
//invalid request
|
invalidFields.push('videoID');
|
||||||
res.status(400).send("Parameters are not valid");
|
}
|
||||||
return;
|
if (typeof userID !== 'string') {
|
||||||
|
invalidFields.push('userID');
|
||||||
|
}
|
||||||
|
if (!Array.isArray(segments) || segments.length < 1) {
|
||||||
|
invalidFields.push('segments');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invalidFields.length !== 0) {
|
||||||
|
// invalid request
|
||||||
|
const fields = invalidFields.reduce((p, c, i) => p + (i !== 0 ? ', ' : '') + c, '');
|
||||||
|
res.status(400).send(`No valid ${fields} field(s) provided`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//hash the userID
|
//hash the userID
|
||||||
|
|
Loading…
Reference in a new issue