mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 04:57:04 +03:00
getLockCategories
- add insertLock
This commit is contained in:
@@ -2,6 +2,9 @@ import { IDatabase } from "../../src/databases/IDatabase";
|
||||
import { HashedUserID } from "../../src/types/user.model";
|
||||
import { User, userArray, usernameUserArray } from "./genUser";
|
||||
import { Feature } from "../../src/types/user.model";
|
||||
import { ActionType, Category, Service, VideoIDHash } from "../../src/types/segments.model";
|
||||
import { genRandomValue } from "./getRandom";
|
||||
import { getHash } from "../../src/utils/getHash";
|
||||
|
||||
// segments
|
||||
export { insertSegment } from "./segmentQueryGen";
|
||||
@@ -46,6 +49,28 @@ export const insertVideoInfo = async (db: IDatabase, videoID: string, channelID:
|
||||
await db.prepare("run", query, [videoID, channelID, title, published]);
|
||||
};
|
||||
|
||||
interface lockParams {
|
||||
videoID?: string,
|
||||
userID?: HashedUserID | "",
|
||||
actionType?: ActionType | string,
|
||||
category?: Category | string,
|
||||
hashedVideoID?: VideoIDHash | "",
|
||||
reason?: string,
|
||||
service?: Service | string
|
||||
}
|
||||
|
||||
export const insertLock = async(db: IDatabase, overrides: lockParams = {}) => {
|
||||
const query = 'INSERT INTO "lockCategories" ("videoID", "userID", "actionType", "category", "hashedVideoID", "reason", "service") VALUES (?, ?, ?, ?, ?, ?, ?)';
|
||||
const identifier = "lock";
|
||||
const defaults = {
|
||||
videoID: genRandomValue("video", identifier), userID: genRandomValue("user", identifier),
|
||||
actionType: "skip", category: "sponsor", hashedVideoID: "", reason: "", service: Service.YouTube
|
||||
};
|
||||
const params = { ...defaults, ...overrides };
|
||||
params.hashedVideoID = getHash(params.videoID);
|
||||
await db.prepare("run", query, Object.values(params));
|
||||
};
|
||||
|
||||
// warning
|
||||
type warningParams = {
|
||||
userID?: HashedUserID,
|
||||
|
||||
Reference in New Issue
Block a user