mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
Allow mute and skip segments with same times
This commit is contained in:
@@ -349,7 +349,7 @@ function checkInvalidFields(videoID: any, userID: any, segments: Array<any>): Ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkEachSegmentValid(userID: string, videoID: VideoID,
|
async function checkEachSegmentValid(userID: string, videoID: VideoID,
|
||||||
segments: Array<any>, service: string, isVIP: boolean, lockedCategoryList: Array<any>): Promise<CheckResult> {
|
segments: IncomingSegment[], service: string, isVIP: boolean, lockedCategoryList: Array<any>): Promise<CheckResult> {
|
||||||
|
|
||||||
for (let i = 0; i < segments.length; i++) {
|
for (let i = 0; i < segments.length; i++) {
|
||||||
if (segments[i] === undefined || segments[i].segment === undefined || segments[i].category === undefined) {
|
if (segments[i] === undefined || segments[i].segment === undefined || segments[i].category === undefined) {
|
||||||
@@ -406,7 +406,7 @@ async function checkEachSegmentValid(userID: string, videoID: VideoID,
|
|||||||
|
|
||||||
//check if this info has already been submitted before
|
//check if this info has already been submitted before
|
||||||
const duplicateCheck2Row = await db.prepare("get", `SELECT COUNT(*) as count FROM "sponsorTimes" WHERE "startTime" = ?
|
const duplicateCheck2Row = await db.prepare("get", `SELECT COUNT(*) as count FROM "sponsorTimes" WHERE "startTime" = ?
|
||||||
and "endTime" = ? and "category" = ? and "videoID" = ? and "service" = ?`, [startTime, endTime, segments[i].category, videoID, service]);
|
and "endTime" = ? and "category" = ? and "actionType" = ? and "videoID" = ? and "service" = ?`, [startTime, endTime, segments[i].category, segments[i].actionType, videoID, service]);
|
||||||
if (duplicateCheck2Row.count > 0) {
|
if (duplicateCheck2Row.count > 0) {
|
||||||
return { pass: false, errorMessage: "Sponsors has already been submitted before.", errorCode: 409};
|
return { pass: false, errorMessage: "Sponsors has already been submitted before.", errorCode: 409};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ import { ActionType, VideoID } from "../types/segments.model";
|
|||||||
import { UserID } from "../types/user.model";
|
import { UserID } from "../types/user.model";
|
||||||
|
|
||||||
export function getSubmissionUUID(videoID: VideoID, actionType: ActionType, userID: UserID, startTime: number, endTime: number): HashedValue{
|
export function getSubmissionUUID(videoID: VideoID, actionType: ActionType, userID: UserID, startTime: number, endTime: number): HashedValue{
|
||||||
return `3${getHash(`v3${videoID}${startTime}${endTime}${userID}`, 1)}` as HashedValue;
|
return `4${getHash(`${videoID}${startTime}${endTime}${userID}${actionType}`, 1)}` as HashedValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ import { UserID } from "../../src/types/user.model";
|
|||||||
|
|
||||||
describe("getSubmissionUUID", () => {
|
describe("getSubmissionUUID", () => {
|
||||||
it("Should return the hashed value", () => {
|
it("Should return the hashed value", () => {
|
||||||
assert.strictEqual(getSubmissionUUID("video001" as VideoID, "skip" as ActionType, "testuser001" as UserID, 13.33337, 42.000001), "3572aa64e0a2d6352c3de14ca45f8a83d193c32635669a7ae0b40c9eb36395872");
|
assert.strictEqual(getSubmissionUUID("video001" as VideoID, "skip" as ActionType, "testuser001" as UserID, 13.33337, 42.000001), "48ad47e445e67a7b963d9200037b36ec706eddcb752fdadc7bb2f061b56be6a23");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user