Merge pull request #444 from mchangrh/full-tests

Tests for full video locks
This commit is contained in:
Ajay Ramachandran
2022-01-16 13:17:19 -05:00
committed by GitHub
10 changed files with 193 additions and 71 deletions

View File

@@ -1,30 +1,32 @@
import { db } from "../databases/databases";
import { Logger } from "../utils/logger";
import { Request, Response } from "express";
import { Category, VideoID } from "../types/segments.model";
import { ActionType, Category, VideoID } from "../types/segments.model";
import { getService } from "../utils/getService";
export async function getLockCategories(req: Request, res: Response): Promise<Response> {
const videoID = req.query.videoID as VideoID;
const service = getService(req.query.service as string);
const actionTypes = req.query.actionTypes as ActionType[] || [ActionType.Skip, ActionType.Mute];
if (videoID == undefined) {
if (!videoID || !Array.isArray(actionTypes)) {
//invalid request
return res.sendStatus(400);
}
try {
// Get existing lock categories markers
const row = await db.prepare("all", 'SELECT "category", "reason" from "lockCategories" where "videoID" = ? AND "service" = ?', [videoID, service]) as {category: Category, reason: string}[];
const row = await db.prepare("all", 'SELECT "category", "reason", "actionType" from "lockCategories" where "videoID" = ? AND "service" = ?', [videoID, service]) as {category: Category, reason: string, actionType: ActionType}[];
const actionTypeMatches = row.filter((lock) => actionTypes.includes(lock.actionType));
// map categories to array in JS becaues of SQL incompatibilities
const categories = row.map(item => item.category);
const categories = actionTypeMatches.map(item => item.category);
if (categories.length === 0 || !categories[0]) return res.sendStatus(404);
// Get longest lock reason
const reason = row.map(item => item.reason)
const reason = actionTypeMatches.map(item => item.reason)
.reduce((a,b) => (a.length > b.length) ? a : b);
return res.send({
reason,
categories
categories,
actionTypes
});
} catch (err) {
Logger.error(err as string);

View File

@@ -2,7 +2,7 @@ import { db } from "../databases/databases";
import { Logger } from "../utils/logger";
import { Request, Response } from "express";
import { hashPrefixTester } from "../utils/hashPrefixTester";
import { Category, VideoID, VideoIDHash } from "../types/segments.model";
import { ActionType, Category, VideoID, VideoIDHash } from "../types/segments.model";
interface LockResultByHash {
videoID: VideoID,
@@ -16,11 +16,13 @@ interface DBLock {
hash: VideoIDHash,
category: Category,
reason: string,
actionType: ActionType,
}
const mergeLocks = (source: DBLock[]) => {
const mergeLocks = (source: DBLock[], actionTypes: ActionType[]) => {
const dest: LockResultByHash[] = [];
for (const obj of source) {
if (!actionTypes.includes(obj.actionType)) continue;
// videoID already exists
const destMatch = dest.find(s => s.videoID === obj.videoID);
if (destMatch) {
@@ -42,6 +44,7 @@ const mergeLocks = (source: DBLock[]) => {
export async function getLockCategoriesByHash(req: Request, res: Response): Promise<Response> {
let hashPrefix = req.params.prefix as VideoIDHash;
const actionTypes = req.query.actionTypes as ActionType[] || [ActionType.Mute, ActionType.Skip];
if (!hashPrefixTester(req.params.prefix)) {
return res.status(400).send("Hash prefix does not match format requirements."); // Exit early on faulty prefix
}
@@ -49,10 +52,10 @@ export async function getLockCategoriesByHash(req: Request, res: Response): Prom
try {
// Get existing lock categories markers
const lockedRows = await db.prepare("all", 'SELECT "videoID", "hashedVideoID" as "hash", "category", "reason" from "lockCategories" where "hashedVideoID" LIKE ?', [`${hashPrefix}%`]) as DBLock[];
const lockedRows = await db.prepare("all", 'SELECT "videoID", "hashedVideoID" as "hash", "category", "reason", "actionType" from "lockCategories" where "hashedVideoID" LIKE ?', [`${hashPrefix}%`]) as DBLock[];
if (lockedRows.length === 0 || !lockedRows[0]) return res.sendStatus(404);
// merge all locks
return res.send(mergeLocks(lockedRows));
return res.send(mergeLocks(lockedRows, actionTypes));
} catch (err) {
Logger.error(err as string);
return res.sendStatus(500);

View File

@@ -1,10 +1,10 @@
import { db } from "../databases/databases";
import { Logger } from "../utils/logger";
import { Request, Response } from "express";
import { Category, VideoID } from "../types/segments.model";
import { Category, VideoID, ActionType } from "../types/segments.model";
import { config } from "../config";
const possibleCategoryList = config.categoryList;
const categorySupportList = config.categorySupport;
interface lockArray {
category: Category;
locked: number,
@@ -13,9 +13,23 @@ interface lockArray {
userName: string,
}
const filterActionType = (actionTypes: ActionType[]) => {
const filterCategories = new Set();
for (const [key, value] of Object.entries(categorySupportList)) {
for (const type of actionTypes) {
if (value.includes(type)) {
filterCategories.add(key as Category);
}
}
}
return [...filterCategories];
};
export async function getLockReason(req: Request, res: Response): Promise<Response> {
const videoID = req.query.videoID as VideoID;
let categories: Category[] = [];
const actionTypes = req.query.actionTypes as ActionType[] || [ActionType.Skip, ActionType.Mute];
const possibleCategories = filterActionType(actionTypes);
try {
categories = req.query.categories
? JSON.parse(req.query.categories as string)
@@ -31,21 +45,25 @@ export async function getLockReason(req: Request, res: Response): Promise<Respon
return res.status(400).send("Bad parameter: categories (invalid JSON)");
}
// only take valid categories
const searchCategories = (categories.length === 0 ) ? possibleCategoryList : categories.filter(x => possibleCategoryList.includes(x));
const searchCategories = (categories.length === 0 )
? possibleCategories
: categories.filter(x =>
possibleCategories.includes(x));
if (videoID == undefined) {
if (!videoID || !Array.isArray(actionTypes)) {
//invalid request
return res.sendStatus(400);
}
try {
// Get existing lock categories markers
const row = await db.prepare("all", 'SELECT "category", "reason", "userID" from "lockCategories" where "videoID" = ?', [videoID]) as {category: Category, reason: string, userID: string }[];
const row = await db.prepare("all", 'SELECT "category", "reason", "actionType", "userID" from "lockCategories" where "videoID" = ?', [videoID]) as {category: Category, reason: string, actionType: ActionType, userID: string }[];
// map to object array
const locks = [];
const userIDs = new Set();
// get all locks for video, check if requested later
for (const lock of row) {
if (actionTypes.includes(lock.actionType))
locks.push({
category: lock.category,
locked: 1,

View File

@@ -389,7 +389,7 @@ async function checkEachSegmentValid(rawIP: IPAddress, paramUserID: UserID, user
|| (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 };
return { pass: false, errorMessage: "One of your segments times are invalid (too short, endTime before startTime, etc.)", errorCode: 400 };
}
// Check for POI segments before some seconds

View File

@@ -28,6 +28,7 @@ export interface SBSConfig {
readOnly: boolean;
webhooks: WebhookConfig[];
categoryList: string[];
categorySupport: Record<string, string[]>;
getTopUsersCacheTimeMinutes: number;
maxNumberOfActiveWarnings: number;
hoursAfterWarningExpires: number;

View File

@@ -1,6 +1,6 @@
import { HashedValue } from "./hash.model";
import { SBRecord } from "./lib.model";
import { UserID } from "./user.model";
import { HashedUserID, UserID } from "./user.model";
export type SegmentUUID = string & { __segmentUUIDBrand: unknown };
export type VideoID = string & { __videoIDBrand: unknown };
@@ -107,11 +107,14 @@ export enum CategoryActionType {
POI
}
export interface LockCategory {
category: Category,
reason: string,
export interface DBLock {
videoID: VideoID,
userID: UserID
userID: HashedUserID,
actionType: ActionType,
category: Category,
hashedVideoID: VideoIDHash,
reason: string,
service: Service,
}
export enum SortableFields {

View File

@@ -4,27 +4,28 @@ import assert from "assert";
import { client } from "../utils/httpClient";
import { mixedDeepEquals } from "../utils/partialDeepEquals";
const endpoint = "/api/lockCategories";
const getLockCategories = (videoID: string) => client.get(endpoint, { params: { videoID } });
const getLockCategoriesWithService = (videoID: string, service: string) => client.get(endpoint, { params: { videoID, service } });
const defaultActionTypes = ["skip", "mute"];
const getLockCategories = (videoID: string, actionTypes = defaultActionTypes, service = "YouTube") => client.get(endpoint, { params: { videoID, actionTypes, service } });
describe("getLockCategories", () => {
before(async () => {
const insertVipUserQuery = 'INSERT INTO "vipUsers" ("userID") VALUES (?)';
await db.prepare("run", insertVipUserQuery, [getHash("getLockCategoriesVIP")]);
const insertLockCategoryQuery = 'INSERT INTO "lockCategories" ("userID", "videoID", "category", "reason", "service") VALUES (?, ?, ?, ?, ?)';
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory1", "sponsor", "1-short", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory1", "interaction", "1-longer-reason", "YouTube"]);
const insertLockCategoryQuery = 'INSERT INTO "lockCategories" ("userID", "videoID", "actionType","category", "reason", "service") VALUES (?, ?, ?, ?, ?, ?)';
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory1", "skip", "sponsor", "1-short", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory1", "mute", "interaction", "1-longer-reason", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory2", "preview", "2-reason", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory2", "skip", "preview", "2-reason", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory3", "nonmusic", "3-reason", "PeerTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory3", "sponsor", "3-reason", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory3", "mute", "nonmusic", "3-reason", "PeerTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory3", "skip", "sponsor", "3-reason", "YouTube"]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesVIP"), "getLockCategory3", "full", "outro", "3-longer-reason", "YouTube"]);
});
it("Should update the database version when starting the application", async () => {
const version = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
assert.ok(version > 20, `Version isn't greater than 20. Version is ${version}`);
assert.ok(version >= 29, `Version isn't greater than 29. Version is ${version}`);
});
it("Should be able to get multiple locks", (done) => {
@@ -36,7 +37,8 @@ describe("getLockCategories", () => {
"sponsor",
"interaction"
],
reason: "1-longer-reason"
reason: "1-longer-reason",
actionTypes: defaultActionTypes
};
assert.ok(mixedDeepEquals(res.data, expected));
done();
@@ -52,7 +54,8 @@ describe("getLockCategories", () => {
categories: [
"preview"
],
reason: "2-reason"
reason: "2-reason",
actionTypes: defaultActionTypes
};
assert.deepStrictEqual(res.data, expected);
done();
@@ -79,7 +82,7 @@ describe("getLockCategories", () => {
});
it("Should be able to get multiple locks with service", (done) => {
getLockCategoriesWithService("getLockCategory1", "YouTube")
getLockCategories("getLockCategory1", defaultActionTypes, "YouTube")
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -87,7 +90,8 @@ describe("getLockCategories", () => {
"sponsor",
"interaction"
],
reason: "1-longer-reason"
reason: "1-longer-reason",
actionTypes: defaultActionTypes
};
assert.ok(mixedDeepEquals(res.data, expected));
done();
@@ -96,14 +100,15 @@ describe("getLockCategories", () => {
});
it("Should be able to get single locks with service", (done) => {
getLockCategoriesWithService("getLockCategory3", "PeerTube")
getLockCategories("getLockCategory3", defaultActionTypes, "PeerTube")
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
categories: [
"nonmusic"
],
reason: "3-reason"
reason: "3-reason",
actionTypes: defaultActionTypes
};
assert.deepStrictEqual(res.data, expected);
done();
@@ -112,14 +117,15 @@ describe("getLockCategories", () => {
});
it("Should be able to get single locks with service", (done) => {
getLockCategoriesWithService("getLockCategory3", "Youtube")
getLockCategories("getLockCategory3", defaultActionTypes, "Youtube")
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
categories: [
"sponsor"
],
reason: "3-reason"
reason: "3-reason",
actionTypes: defaultActionTypes
};
assert.deepStrictEqual(res.data, expected);
done();
@@ -128,18 +134,65 @@ describe("getLockCategories", () => {
});
it("should return result from Youtube service if service not match", (done) => {
getLockCategoriesWithService("getLockCategory3", "Dailymotion")
getLockCategories("getLockCategory3", defaultActionTypes, "Dailymotion")
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
categories: [
"sponsor"
],
reason: "3-reason"
reason: "3-reason",
actionTypes: defaultActionTypes
};
assert.deepStrictEqual(res.data, expected);
done();
})
.catch(err => done(err));
});
it("should return 404 if invalid actionTypes specified", (done) => {
getLockCategories("getLockCategory1", ["ban"])
.then(res => {
assert.strictEqual(res.status, 404);
done();
})
.catch(err => done(err));
});
it("should be able to get with specific actionType", (done) => {
getLockCategories("getLockCategory1", ["mute"])
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
categories: [
"sponsor",
"interaction"
],
reason: "1-longer-reason",
actionTypes: ["mute"]
};
mixedDeepEquals(res.data, expected);
done();
})
.catch(err => done(err));
});
it("Should be able to get skip, mute, full", (done) => {
const actionTypes = [...defaultActionTypes, "full"];
getLockCategories("getLockCategory3", actionTypes)
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
categories: [
"nonmusic",
"outro"
],
reason: "3-longer-reason",
actionTypes
};
mixedDeepEquals(res.data, expected);
done();
})
.catch(err => done(err));
});
});

View File

@@ -2,34 +2,36 @@ import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
import { client } from "../utils/httpClient";
import { ActionType } from "../../src/types/segments.model";
const fakeHash = "b05a20424f24a53dac1b059fb78d861ba9723645026be2174c93a94f9106bb35";
const endpoint = "/api/lockCategories";
const getLockCategories = (hash: string) => client.get(`${endpoint}/${hash}`);
const getLockCategories = (hash: string, actionTypes = [ActionType.Mute, ActionType.Skip]) => client.get(`${endpoint}/${hash}`, { params: { actionTypes } });
describe("getLockCategoriesByHash", () => {
before(async () => {
const insertVipUserQuery = 'INSERT INTO "vipUsers" ("userID") VALUES (?)';
await db.prepare("run", insertVipUserQuery, [getHash("getLockCategoriesHashVIP")]);
const insertLockCategoryQuery = 'INSERT INTO "lockCategories" ("userID", "videoID", "category", "reason", "hashedVideoID") VALUES (?, ?, ?, ?, ?)';
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash1", "sponsor", "1-reason-short", getHash("getLockHash1", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash1", "interaction", "1-reason-longer", getHash("getLockHash1", 1)]);
const insertLockCategoryQuery = 'INSERT INTO "lockCategories" ("userID", "videoID", "actionType", "category", "reason", "hashedVideoID") VALUES (?, ?, ?, ?, ?, ?)';
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash1", "skip", "sponsor", "1-reason-short", getHash("getLockHash1", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash1", "skip", "interaction", "1-reason-longer", getHash("getLockHash1", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash2", "preview", "2-reason", getHash("getLockHash2", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash2", "skip", "preview", "2-reason", getHash("getLockHash2", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash3", "nonmusic", "3-reason", getHash("getLockHash3", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "getLockHash3", "skip", "nonmusic", "3-reason", getHash("getLockHash3", 1)]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-1", "outro", "fake1-reason", fakeHash]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-2", "intro", "fake2-longer-reason", fakeHash]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-2", "preview", "fake2-short", fakeHash]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-1", "mute", "outro", "fake1-reason", fakeHash]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-2", "mute", "intro", "fake2-longer-reason", fakeHash]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-2", "mute", "preview", "fake2-short", fakeHash]);
await db.prepare("run", insertLockCategoryQuery, [getHash("getLockCategoriesHashVIP"), "fakehash-2", "full", "sponsor", "fake2-notshown", fakeHash]);
});
it("Database should be greater or equal to version 20", async () => {
it("Database should be greater or equal to version 29", async () => {
const version = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
assert(
version >= 20,
`Version isn't greater than 20. Version is ${version}`);
version >= 29,
`Version isn't greater than 29. Version is ${version}`);
});
it("Should be able to get multiple locks in one object", (done) => {
@@ -163,4 +165,22 @@ describe("getLockCategoriesByHash", () => {
})
.catch(err => done(err));
});
it("Should be able to get by actionType", (done) => {
getLockCategories(fakeHash.substring(0,5), [ActionType.Full])
.then(res => {
assert.strictEqual(res.status, 200);
const expected = [{
videoID: "fakehash-2",
hash: fakeHash,
categories: [
"sponsor"
],
reason: "fake2-notshown"
}];
assert.deepStrictEqual(res.data, expected);
done();
})
.catch(err => done(err));
});
});

View File

@@ -2,6 +2,7 @@ import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
import { client } from "../utils/httpClient";
import { partialDeepEquals } from "../utils/partialDeepEquals";
const endpoint = "/api/lockReason";
@@ -20,12 +21,13 @@ describe("getLockReason", () => {
await db.prepare("run", insertVipUserNameQuery, [vipUserID1, vipUserName1]);
await db.prepare("run", insertVipUserNameQuery, [vipUserID2, vipUserName2]);
const insertLockCategoryQuery = 'INSERT INTO "lockCategories" ("userID", "videoID", "category", "reason") VALUES (?, ?, ?, ?)';
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "sponsor", "sponsor-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "interaction", "interaction-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "preview", "preview-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "music_offtopic", "nonmusic-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID2, "getLockReason", "outro", "outro-reason"]);
const insertLockCategoryQuery = 'INSERT INTO "lockCategories" ("userID", "videoID", "actionType", "category", "reason") VALUES (?, ?, ?, ?, ?)';
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "skip", "sponsor", "sponsor-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "skip", "interaction", "interaction-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "skip", "preview", "preview-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID1, "getLockReason", "mute", "music_offtopic", "nonmusic-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID2, "getLockReason", "mute", "outro", "outro-reason"]);
await db.prepare("run", insertLockCategoryQuery, [vipUserID2, "getLockReason", "full", "selfpromo", "selfpromo-reason"]);
});
after(async () => {
@@ -96,7 +98,7 @@ describe("getLockReason", () => {
.catch(err => done(err));
});
it("should return all categories if none specified", (done) => {
it("should return all skip + mute categories if none specified", (done) => {
client.get(endpoint, { params: { videoID: "getLockReason" } })
.then(res => {
assert.strictEqual(res.status, 200);
@@ -110,10 +112,8 @@ describe("getLockReason", () => {
{ category: "preview", locked: 1, reason: "preview-reason", userID: vipUserID1, userName: vipUserName1 },
{ category: "music_offtopic", locked: 1, reason: "nonmusic-reason", userID: vipUserID1, userName: vipUserName1 },
{ category: "filler", locked: 0, reason: "", userID: "", userName: "" },
{ category: "poi_highlight", locked: 0, reason: "", userID: "", userName: "" },
{ category: "chapter", locked: 0, reason: "", userID: "", userName: "" }
];
assert.deepStrictEqual(res.data, expected);
partialDeepEquals(res.data, expected, false);
done();
})
.catch(err => done(err));
@@ -127,4 +127,18 @@ describe("getLockReason", () => {
})
.catch(err => done(err));
});
it("should be able to get by actionType", (done) => {
client.get(endpoint, { params: { videoID: "getLockReason", actionTypes: ["full"] } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = [
{ category: "selfpromo", locked: 1, reason: "sponsor-reason", userID: vipUserID2, userName: vipUserName2 },
{ category: "sponsor", locked: 0, reason: "", userID: "", userName: "" }
];
partialDeepEquals(res.data, expected);
done();
})
.catch(err => done(err));
});
});

View File

@@ -1,7 +1,8 @@
import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
import { LockCategory } from "../../src/types/segments.model";
import { UserID } from "../../src/types/user.model";
import { Category, VideoID } from "../../src/types/segments.model";
import { client } from "../utils/httpClient";
import { partialDeepEquals } from "../utils/partialDeepEquals";
@@ -13,6 +14,13 @@ const stringDeepEquals = (a: string[], b: string[]): boolean => {
return result;
};
interface LockCategory {
category: Category,
reason: string,
videoID: VideoID,
userID: UserID
}
const endpoint = "/api/lockCategories";
const submitEndpoint = "/api/skipSegments";
const checkLockCategories = (videoID: string): Promise<LockCategory[]> => db.prepare("all", 'SELECT * FROM "lockCategories" WHERE "videoID" = ?', [videoID]);