From 51d25cfc6862453c2a65c93714ce8c4f8524fc3b Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 29 Jan 2023 13:53:08 -0500 Subject: [PATCH] Ban users submitting from banned IPs --- src/routes/postSkipSegments.ts | 12 ++++++++++-- src/routes/shadowBanUser.ts | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index 1347a89..630fb70 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -23,6 +23,7 @@ import { vote } from "./voteOnSponsorTime"; import { canSubmit } from "../utils/permissions"; import { getVideoDetails, videoDetails } from "../utils/getVideoDetails"; import * as youtubeID from "../utils/youtubeID"; +import { banUser } from "./shadowBanUser"; type CheckResult = { pass: boolean, @@ -541,11 +542,18 @@ export async function postSkipSegments(req: Request, res: Response): Promise Logger.error(`Error banning user after submitting from a banned IP: ${e}`)); + } + for (const segmentInfo of segments) { // Full segments are always rejected since there can only be one, so shadow hide wouldn't work if (segmentInfo.ignoreSegment diff --git a/src/routes/shadowBanUser.ts b/src/routes/shadowBanUser.ts index 1f83805..e0e9112 100644 --- a/src/routes/shadowBanUser.ts +++ b/src/routes/shadowBanUser.ts @@ -70,7 +70,7 @@ export async function shadowBanUser(req: Request, res: Response): Promise { +export async function banUser(userID: UserID, enabled: boolean, unHideOldSubmissions: boolean, type: string, categories: Category[]): Promise { //check to see if this user is already shadowbanned const row = await db.prepare("get", `SELECT count(*) as "userCount" FROM "shadowBannedUsers" WHERE "userID" = ?`, [userID]); @@ -123,7 +123,7 @@ async function banUser(userID: UserID, enabled: boolean, unHideOldSubmissions: b return 200; } -async function banIP(hashedIP: HashedIP, enabled: boolean, unHideOldSubmissions: boolean, type: string, categories: Category[], banUsers: boolean): Promise { +export async function banIP(hashedIP: HashedIP, enabled: boolean, unHideOldSubmissions: boolean, type: string, categories: Category[], banUsers: boolean): Promise { //check to see if this user is already shadowbanned const row = await db.prepare("get", `SELECT count(*) as "userCount" FROM "shadowBannedIPs" WHERE "hashedIP" = ?`, [hashedIP]);