Merge pull request #345 from mchangrh/poi-restriction

disallow POI before 1 second
This commit is contained in:
Ajay Ramachandran
2021-08-28 16:18:52 -04:00
committed by GitHub
2 changed files with 18 additions and 1 deletions

View File

@@ -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}; 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) { if (!isVIP && segments[i].category === "sponsor" && Math.abs(startTime - endTime) < 1) {
// Too short // Too short
return { pass: false, errorMessage: "Sponsors must be longer than 1 second long", errorCode: 400}; return { pass: false, errorMessage: "Sponsors must be longer than 1 second long", errorCode: 400};

View File

@@ -988,6 +988,18 @@ describe("postSkipSegments", () => {
.catch(err => done(err)); .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) => { it("Should not be able to submit with colons in timestamps", (done: Done) => {
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, { fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
method: "POST", method: "POST",
@@ -1003,7 +1015,7 @@ describe("postSkipSegments", () => {
}] }]
}), }),
}) })
.then(async res => { .then(res => {
assert.strictEqual(res.status, 400); assert.strictEqual(res.status, 400);
done(); done();
}) })