mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-10 21:47:02 +03:00
Allow submitting full sponsors and selfpromo
This commit is contained in:
@@ -21,8 +21,8 @@ addDefaults(config, {
|
||||
webhooks: [],
|
||||
categoryList: ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "filler", "poi_highlight", "chapter"],
|
||||
categorySupport: {
|
||||
sponsor: ["skip", "mute"],
|
||||
selfpromo: ["skip", "mute"],
|
||||
sponsor: ["skip", "mute", "full"],
|
||||
selfpromo: ["skip", "mute", "full"],
|
||||
interaction: ["skip", "mute"],
|
||||
intro: ["skip", "mute"],
|
||||
outro: ["skip", "mute"],
|
||||
|
||||
@@ -383,8 +383,10 @@ async function checkEachSegmentValid(userID: string, videoID: VideoID,
|
||||
|
||||
if (isNaN(startTime) || isNaN(endTime)
|
||||
|| startTime === Infinity || endTime === Infinity || startTime < 0 || startTime > endTime
|
||||
|| (getCategoryActionType(segments[i].category) === CategoryActionType.Skippable && startTime === endTime)
|
||||
|| (getCategoryActionType(segments[i].category) === CategoryActionType.POI && startTime !== endTime)) {
|
||||
|| (getCategoryActionType(segments[i].category) === CategoryActionType.Skippable
|
||||
&& segments[i].actionType !== ActionType.Full && startTime === endTime)
|
||||
|| (getCategoryActionType(segments[i].category) === CategoryActionType.POI && startTime !== endTime)
|
||||
|| (segments[i].actionType === ActionType.Full && (startTime !== 0 || endTime !== 0))) {
|
||||
//invalid request
|
||||
return { pass: false, errorMessage: "One of your segments times are invalid (too short, startTime before endTime, etc.)", errorCode: 400 };
|
||||
}
|
||||
@@ -394,7 +396,8 @@ async function checkEachSegmentValid(userID: string, videoID: VideoID,
|
||||
return { pass: false, errorMessage: `POI cannot be that early`, errorCode: 400 };
|
||||
}
|
||||
|
||||
if (!isVIP && segments[i].category === "sponsor" && Math.abs(startTime - endTime) < 1) {
|
||||
if (!isVIP && segments[i].category === "sponsor"
|
||||
&& segments[i].actionType !== ActionType.Full && Math.abs(startTime - endTime) < 1) {
|
||||
// Too short
|
||||
return { pass: false, errorMessage: "Sponsors must be longer than 1 second long", errorCode: 400 };
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ export type HashedIP = IPAddress & HashedValue;
|
||||
export enum ActionType {
|
||||
Skip = "skip",
|
||||
Mute = "mute",
|
||||
Chapter = "chapter"
|
||||
Chapter = "chapter",
|
||||
Full = "full"
|
||||
}
|
||||
|
||||
// Uncomment as needed
|
||||
|
||||
@@ -1064,6 +1064,40 @@ describe("postSkipSegments", () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should allow submitting full video sponsor", (done) => {
|
||||
const videoID = "qqwerth";
|
||||
postSkipSegmentParam({
|
||||
videoID,
|
||||
startTime: 0,
|
||||
endTime: 0,
|
||||
category: "sponsor",
|
||||
actionType: "full",
|
||||
userID: submitUserTwo
|
||||
})
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should not allow submitting full video sponsor not at zero seconds", (done) => {
|
||||
const videoID = "qqwerth";
|
||||
postSkipSegmentParam({
|
||||
videoID,
|
||||
startTime: 0,
|
||||
endTime: 1,
|
||||
category: "sponsor",
|
||||
actionType: "full",
|
||||
userID: submitUserTwo
|
||||
})
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 400);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should not be able to submit with colons in timestamps", (done) => {
|
||||
const videoID = "colon-1";
|
||||
postSkipSegmentJSON({
|
||||
|
||||
Reference in New Issue
Block a user