mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 16:37:12 +03:00
remove extra async and extra utils
This commit is contained in:
@@ -10,6 +10,7 @@ export class Mysql implements IDatabase {
|
||||
constructor(private config: unknown) {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line require-await
|
||||
async init(): Promise<void> {
|
||||
this.connection = new MysqlInterface(this.config);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export class Sqlite implements IDatabase {
|
||||
{
|
||||
}
|
||||
|
||||
// eslint-disable-next-line require-await
|
||||
async prepare(type: QueryType, query: string, params: any[] = []): Promise<any[]> {
|
||||
// Logger.debug(`prepare (sqlite): type: ${type}, query: ${query}, params: ${params}`);
|
||||
const preparedQuery = this.db.prepare(query);
|
||||
@@ -30,6 +31,7 @@ export class Sqlite implements IDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line require-await
|
||||
async init(): Promise<void> {
|
||||
// Make dirs if required
|
||||
if (!fs.existsSync(path.join(this.config.dbPath, "../"))) {
|
||||
|
||||
@@ -10,7 +10,7 @@ type searchSegmentResponse = {
|
||||
segments: DBSegment[]
|
||||
};
|
||||
|
||||
async function getSegmentsFromDBByVideoID(videoID: VideoID, service: Service): Promise<DBSegment[]> {
|
||||
function getSegmentsFromDBByVideoID(videoID: VideoID, service: Service): Promise<DBSegment[]> {
|
||||
return db.prepare(
|
||||
"all",
|
||||
`SELECT "UUID", "timeSubmitted", "startTime", "endTime", "category", "actionType", "votes", "views", "locked", "hidden", "shadowHidden" FROM "sponsorTimes"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { hashPrefixTester } from "../utils/hashPrefixTester";
|
||||
import { getSegmentsByHash } from "./getSkipSegments";
|
||||
import { Request, Response } from "express";
|
||||
import { ActionType, Category, SegmentUUID, Service, VideoIDHash } from "../types/segments.model";
|
||||
import { ActionType, Category, SegmentUUID, VideoIDHash } from "../types/segments.model";
|
||||
import { getService } from "../utils/getService";
|
||||
|
||||
export async function getSkipSegmentsByHash(req: Request, res: Response): Promise<Response> {
|
||||
|
||||
@@ -116,7 +116,7 @@ const objSwitch = (cases: cases) => (defaultCase: string) => (key: string) =>
|
||||
const functionSwitch = (cases: cases) => (defaultCase: string) => (key: string) =>
|
||||
executeIfFunction(objSwitch(cases)(defaultCase)(key));
|
||||
|
||||
const dbGetValue = async (userID: HashedUserID, property: string): Promise<string|SegmentUUID|number> => {
|
||||
const dbGetValue = (userID: HashedUserID, property: string): Promise<string|SegmentUUID|number> => {
|
||||
return functionSwitch({
|
||||
userID,
|
||||
userName: dbGetUsername(userID),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { postSkipSegments } from "./postSkipSegments";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function oldSubmitSponsorTimes(req: Request, res: Response): Promise<Response> {
|
||||
export function oldSubmitSponsorTimes(req: Request, res: Response): Promise<Response> {
|
||||
req.query.category = "sponsor";
|
||||
return postSkipSegments(req, res);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ async function autoModerateSubmission(apiVideoInfo: APIVideoInfo,
|
||||
}
|
||||
}
|
||||
|
||||
async function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<APIVideoInfo> {
|
||||
function getYouTubeVideoInfo(videoID: VideoID, ignoreCache = false): Promise<APIVideoInfo> {
|
||||
if (config.newLeafURLs !== null) {
|
||||
return YouTubeAPI.listVideos(videoID, ignoreCache);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { db, privateDB } from "../databases/databases";
|
||||
import { getHash } from "../utils/getHash";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
async function logUserNameChange(userID: string, newUserName: string, oldUserName: string, updatedByAdmin: boolean): Promise<Response> {
|
||||
function logUserNameChange(userID: string, newUserName: string, oldUserName: string, updatedByAdmin: boolean): Promise<Response> {
|
||||
return privateDB.prepare("run",
|
||||
`INSERT INTO "userNameLogs"("userID", "newUserName", "oldUserName", "updatedByAdmin", "updatedAt") VALUES(?, ?, ?, ?, ?)`,
|
||||
[userID, newUserName, oldUserName, + updatedByAdmin, new Date().getTime()]
|
||||
|
||||
Reference in New Issue
Block a user