From 5965879ed11c526631a6b4e45f2acef3abf0c96a Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 17 Aug 2021 22:01:12 -0400 Subject: [PATCH] Rename highlight category to poi_highlight --- ci.json | 2 +- config.json.example | 2 +- src/config.ts | 2 +- src/types/segments.model.ts | 2 +- src/utils/categoryInfo.ts | 5 ++--- test.json | 2 +- test/cases/getSkipSegmentsByHash.ts | 4 ++-- test/cases/postSkipSegments.ts | 4 ++-- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ci.json b/ci.json index f6e1c7b..32ef176 100644 --- a/ci.json +++ b/ci.json @@ -46,7 +46,7 @@ ] } ], - "categoryList": ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "highlight"], + "categoryList": ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight"], "maxNumberOfActiveWarnings": 3, "hoursAfterWarningExpires": 24, "rateLimit": { diff --git a/config.json.example b/config.json.example index 8a94d22..2445ba9 100644 --- a/config.json.example +++ b/config.json.example @@ -23,7 +23,7 @@ "mode": "development", "readOnly": false, "webhooks": [], - "categoryList": ["sponsor", "intro", "outro", "interaction", "selfpromo", "preview", "music_offtopic", "highlight"], // List of supported categories any other category will be rejected + "categoryList": ["sponsor", "intro", "outro", "interaction", "selfpromo", "preview", "music_offtopic", "poi_highlight"], // List of supported categories any other category will be rejected "getTopUsersCacheTimeMinutes": 5, // cacheTime for getTopUsers result in minutes "maxNumberOfActiveWarnings": 3, // Users with this number of warnings will be blocked until warnings expire "hoursAfterWarningExpire": 24, diff --git a/src/config.ts b/src/config.ts index ea3a562..cb985ab 100644 --- a/src/config.ts +++ b/src/config.ts @@ -19,7 +19,7 @@ addDefaults(config, { privateDBSchema: "./databases/_private.db.sql", readOnly: false, webhooks: [], - categoryList: ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "highlight"], + categoryList: ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight"], maxNumberOfActiveWarnings: 1, hoursAfterWarningExpires: 24, adminUserID: "", diff --git a/src/types/segments.model.ts b/src/types/segments.model.ts index fd0cb0e..be4745f 100644 --- a/src/types/segments.model.ts +++ b/src/types/segments.model.ts @@ -5,7 +5,7 @@ import { UserID } from "./user.model"; export type SegmentUUID = string & { __segmentUUIDBrand: unknown }; export type VideoID = string & { __videoIDBrand: unknown }; export type VideoDuration = number & { __videoDurationBrand: unknown }; -export type Category = ("sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "highlight") & { __categoryBrand: unknown }; +export type Category = ("sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "poi_highlight") & { __categoryBrand: unknown }; export type VideoIDHash = VideoID & HashedValue; export type IPAddress = string & { __ipAddressBrand: unknown }; export type HashedIP = IPAddress & HashedValue; diff --git a/src/utils/categoryInfo.ts b/src/utils/categoryInfo.ts index b99237a..d573128 100644 --- a/src/utils/categoryInfo.ts +++ b/src/utils/categoryInfo.ts @@ -1,10 +1,9 @@ import { Category, CategoryActionType } from "../types/segments.model"; export function getCategoryActionType(category: Category): CategoryActionType { - switch (category) { - case "highlight": + if (category.startsWith("poi_")) { return CategoryActionType.POI; - default: + } else { return CategoryActionType.Skippable; } } diff --git a/test.json b/test.json index db714b9..a4b7be4 100644 --- a/test.json +++ b/test.json @@ -42,7 +42,7 @@ ] } ], - "categoryList": ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "highlight"], + "categoryList": ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "poi_highlight"], "maxNumberOfActiveWarnings": 3, "hoursAfterWarningExpires": 24, "rateLimit": { diff --git a/test/cases/getSkipSegmentsByHash.ts b/test/cases/getSkipSegmentsByHash.ts index 4c1634a..4079f65 100644 --- a/test/cases/getSkipSegmentsByHash.ts +++ b/test/cases/getSkipSegmentsByHash.ts @@ -21,8 +21,8 @@ describe("getSkipSegmentsByHash", () => { await db.prepare("run", query, ["getSegmentsByHash-noMatchHash", 40, 50, 2, "getSegmentsByHash-noMatchHash", "testman", 0, 50, "sponsor", "skip", "YouTube", 0, 0, "fdaffnoMatchHash"]); await db.prepare("run", query, ["getSegmentsByHash-1", 60, 70, 2, "getSegmentsByHash-1", "testman", 0, 50, "sponsor", "skip", "YouTube", 0, 0, "3272fa85ee0927f6073ef6f07ad5f3146047c1abba794cfa364d65ab9921692b"]); await db.prepare("run", query, ["onlyHidden", 60, 70, 2, "onlyHidden", "testman", 0, 50, "sponsor", "skip", "YouTube", 1, 0, "f3a199e1af001d716cdc6599360e2b062c2d2b3fa2885f6d9d2fd741166cbbd3"]); - await db.prepare("run", query, ["highlightVid", 60, 60, 2, "highlightVid-1", "testman", 0, 50, "highlight", "skip", "YouTube", 0, 0, getHash("highlightVid", 1)]); - await db.prepare("run", query, ["highlightVid", 70, 70, 2, "highlightVid-2", "testman", 0, 50, "highlight", "skip", "YouTube", 0, 0, getHash("highlightVid", 1)]); + await db.prepare("run", query, ["highlightVid", 60, 60, 2, "highlightVid-1", "testman", 0, 50, "poi_highlight", "skip", "YouTube", 0, 0, getHash("highlightVid", 1)]); + await db.prepare("run", query, ["highlightVid", 70, 70, 2, "highlightVid-2", "testman", 0, 50, "poi_highlight", "skip", "YouTube", 0, 0, getHash("highlightVid", 1)]); await db.prepare("run", query, ["requiredSegmentVid", 60, 70, 2, "requiredSegmentVid-1", "testman", 0, 50, "sponsor", "skip", "YouTube", 0, 0, "d51822c3f681e07aef15a8855f52ad12db9eb9cf059e65b16b64c43359557f61"]); await db.prepare("run", query, ["requiredSegmentVid", 60, 70, -2, "requiredSegmentVid-2", "testman", 0, 50, "sponsor", "skip", "YouTube", 0, 0, "d51822c3f681e07aef15a8855f52ad12db9eb9cf059e65b16b64c43359557f61"]); await db.prepare("run", query, ["requiredSegmentVid", 80, 90, -2, "requiredSegmentVid-3", "testman", 0, 50, "sponsor", "skip", "YouTube", 0, 0, "d51822c3f681e07aef15a8855f52ad12db9eb9cf059e65b16b64c43359557f61"]); diff --git a/test/cases/postSkipSegments.ts b/test/cases/postSkipSegments.ts index d7643af..b6643c2 100644 --- a/test/cases/postSkipSegments.ts +++ b/test/cases/postSkipSegments.ts @@ -536,7 +536,7 @@ describe("postSkipSegments", () => { it("Should be accepted if highlight segment starts and ends at the same time", (done: Done) => { fetch(`${getbaseURL() - }/api/skipSegments?videoID=qqwerty&startTime=30&endTime=30&userID=testtesttesttesttesttesttesttesttesting&category=highlight`, { + }/api/skipSegments?videoID=qqwerty&startTime=30&endTime=30&userID=testtesttesttesttesttesttesttesttesting&category=poi_highlight`, { method: "POST", }) .then(res => { @@ -548,7 +548,7 @@ describe("postSkipSegments", () => { it("Should be rejected if highlight segment doesn't start and end at the same time", (done: Done) => { fetch(`${getbaseURL() - }/api/skipSegments?videoID=qqwerty&startTime=30&endTime=30.5&userID=testtesttesttesttesttesttesttesttesting&category=highlight`, { + }/api/skipSegments?videoID=qqwerty&startTime=30&endTime=30.5&userID=testtesttesttesttesttesttesttesttesting&category=poi_highlight`, { method: "POST", }) .then(res => {