mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 11:36:58 +03:00
Merge pull request #345 from mchangrh/poi-restriction
disallow POI before 1 second
This commit is contained in:
@@ -390,6 +390,11 @@ async function checkEachSegmentValid(userID: string, videoID: VideoID
|
||||
return { pass: false, errorMessage: "One of your segments times are invalid (too short, startTime before endTime, etc.)", errorCode: 400};
|
||||
}
|
||||
|
||||
// Check for POI segments before 1 second
|
||||
if (getCategoryActionType(segments[i].category) === CategoryActionType.POI && startTime < 1) {
|
||||
return { pass: false, errorMessage: "POI must be after 1 second", errorCode: 400};
|
||||
}
|
||||
|
||||
if (!isVIP && segments[i].category === "sponsor" && Math.abs(startTime - endTime) < 1) {
|
||||
// Too short
|
||||
return { pass: false, errorMessage: "Sponsors must be longer than 1 second long", errorCode: 400};
|
||||
|
||||
@@ -988,6 +988,18 @@ describe("postSkipSegments", () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be rejected if a POI is at less than 1 second", (done: Done) => {
|
||||
fetch(`${getbaseURL()
|
||||
}/api/skipSegments?videoID=qqwerty&startTime=0.5&endTime=0.5&category=poi_highlight&userID=testtesttesttesttesttesttesttesttesting`, {
|
||||
method: "POST",
|
||||
})
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 400);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should not be able to submit with colons in timestamps", (done: Done) => {
|
||||
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
|
||||
method: "POST",
|
||||
@@ -1003,7 +1015,7 @@ describe("postSkipSegments", () => {
|
||||
}]
|
||||
}),
|
||||
})
|
||||
.then(async res => {
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 400);
|
||||
done();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user