diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index c18e38b..30cef25 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -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}; diff --git a/test/cases/postSkipSegments.ts b/test/cases/postSkipSegments.ts index de502e1..cc61761 100644 --- a/test/cases/postSkipSegments.ts +++ b/test/cases/postSkipSegments.ts @@ -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(); })