mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-05-10 18:06:08 +02:00
Save user agent for dearrow
This commit is contained in:
parent
ed5a397a30
commit
3d596f4528
2 changed files with 14 additions and 4 deletions
8
databases/_upgrade_sponsorTimes_44.sql
Normal file
8
databases/_upgrade_sponsorTimes_44.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE "titles" ADD "userAgent" TEXT NOT NULL default '';
|
||||
ALTER TABLE "thumbnails" ADD "userAgent" TEXT NOT NULL default '';
|
||||
|
||||
UPDATE "config" SET value = 44 WHERE key = 'version';
|
||||
|
||||
COMMIT;
|
|
@ -19,6 +19,7 @@ import axios from "axios";
|
|||
import { getMaxResThumbnail } from "../utils/youtubeApi";
|
||||
import { getVideoDetails } from "../utils/getVideoDetails";
|
||||
import { canSubmitDeArrow } from "../utils/permissions";
|
||||
import { parseUserAgent } from "../utils/userAgent";
|
||||
|
||||
enum BrandingType {
|
||||
Title,
|
||||
|
@ -39,6 +40,7 @@ interface ExistingVote {
|
|||
export async function postBranding(req: Request, res: Response) {
|
||||
const { videoID, userID, title, thumbnail, autoLock, downvote, videoDuration, wasWarned, casualMode } = req.body as BrandingSubmission;
|
||||
const service = getService(req.body.service);
|
||||
const userAgent = req.body.userAgent ?? parseUserAgent(req.get("user-agent")) ?? "";
|
||||
|
||||
if (!videoID || !userID || userID.length < 30 || !service
|
||||
|| ((!title || !title.title)
|
||||
|
@ -109,8 +111,8 @@ export async function postBranding(req: Request, res: Response) {
|
|||
throw new Error("Title submission doesn't exist");
|
||||
}
|
||||
|
||||
await db.prepare("run", `INSERT INTO "titles" ("videoID", "title", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID", "casualMode") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[videoID, title.title, title.original ? 1 : 0, hashedUserID, service, hashedVideoID, now, UUID, casualMode ? 1 : 0]);
|
||||
await db.prepare("run", `INSERT INTO "titles" ("videoID", "title", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID", "casualMode", "userAgent") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[videoID, title.title, title.original ? 1 : 0, hashedUserID, service, hashedVideoID, now, UUID, casualMode ? 1 : 0, userAgent]);
|
||||
|
||||
const verificationValue = await getVerificationValue(hashedUserID, isVip);
|
||||
await db.prepare("run", `INSERT INTO "titleVotes" ("UUID", "votes", "locked", "shadowHidden", "verification") VALUES (?, 0, ?, ?, ?);`,
|
||||
|
@ -151,8 +153,8 @@ export async function postBranding(req: Request, res: Response) {
|
|||
throw new Error("Thumbnail submission doesn't exist");
|
||||
}
|
||||
|
||||
await db.prepare("run", `INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID", "casualMode") VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[videoID, thumbnail.original ? 1 : 0, hashedUserID, service, hashedVideoID, now, UUID, casualMode ? 1 : 0]);
|
||||
await db.prepare("run", `INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID", "casualMode", "userAgent") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[videoID, thumbnail.original ? 1 : 0, hashedUserID, service, hashedVideoID, now, UUID, casualMode ? 1 : 0, userAgent]);
|
||||
|
||||
await db.prepare("run", `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, 0, ?, ?)`,
|
||||
[UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue