Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into searchSegments

This commit is contained in:
Michael C
2021-09-01 23:26:55 -04:00
7 changed files with 59 additions and 2 deletions

18
src/routes/getStatus.ts Normal file
View File

@@ -0,0 +1,18 @@
import {db} from "../databases/databases";
import {Logger} from "../utils/logger";
import {Request, Response} from "express";
export async function getStatus(req: Request, res: Response): Promise<Response> {
try {
const dbVersion = (await db.prepare("get", "SELECT key, value FROM config where key = ?", ["version"])).value;
return res.send({
uptime: process.uptime(),
commit: (global as any).HEADCOMMIT || "unknown",
db: Number(dbVersion),
});
} catch (err) {
Logger.error(err as string);
return res.sendStatus(500);
}
}

View File

@@ -431,7 +431,7 @@ export async function voteOnSponsorTime(req: Request, res: Response): Promise<Re
await db.prepare("run", `UPDATE "sponsorTimes" SET "${columnName}" = "${columnName}" + ? WHERE "UUID" = ?`, [incrementAmount - oldIncrementAmount, UUID]);
if (isVIP && incrementAmount > 0 && voteTypeEnum === voteTypes.normal) {
// Unide and Lock this submission
await db.prepare("run", 'UPDATE "sponsorTimes" SET locked = 1, hidden = 0 WHERE "UUID" = ?', [UUID]);
await db.prepare("run", 'UPDATE "sponsorTimes" SET locked = 1, hidden = 0, "shadowHidden" = 0 WHERE "UUID" = ?', [UUID]);
// Reset video duration in case that caused it to be hidden
if (videoInfo.hidden) await db.prepare("run", 'UPDATE "sponsorTimes" SET "videoDuration" = 0 WHERE "UUID" = ?', [UUID]);