diff --git a/src/routes/addUserAsVIP.ts b/src/routes/addUserAsVIP.ts index 919d308..bd976f0 100644 --- a/src/routes/addUserAsVIP.ts +++ b/src/routes/addUserAsVIP.ts @@ -2,9 +2,12 @@ import {getHash} from "../utils/getHash"; import {db} from "../databases/databases"; import {config} from "../config"; import {Request, Response} from "express"; +import { isUserVIP } from "../utils/isUserVIP"; +import { HashedUserID } from "../types/user.model"; + export async function addUserAsVIP(req: Request, res: Response): Promise { - const userID = req.query.userID as string; + const userID = req.query.userID as HashedUserID; let adminUserIDInput = req.query.adminUserID as string; const enabled = req.query.enabled === undefined @@ -25,12 +28,12 @@ export async function addUserAsVIP(req: Request, res: Response): Promise 0) { + } else if (!enabled && userIsVIP) { //remove them from the shadow ban list await db.prepare("run", 'DELETE FROM "vipUsers" WHERE "userID" = ?', [userID]); } diff --git a/src/routes/shadowBanUser.ts b/src/routes/shadowBanUser.ts index 98ae6e4..3ecb653 100644 --- a/src/routes/shadowBanUser.ts +++ b/src/routes/shadowBanUser.ts @@ -5,11 +5,12 @@ import { config } from "../config"; import { Category, Service, VideoID, VideoIDHash } from "../types/segments.model"; import { UserID } from "../types/user.model"; import { QueryCacher } from "../utils/queryCacher"; +import { isUserVIP } from "../utils/isUserVIP"; export async function shadowBanUser(req: Request, res: Response): Promise { - const userID = req.query.userID as string; + const userID = req.query.userID as UserID; const hashedIP = req.query.hashedIP as string; - let adminUserIDInput = req.query.adminUserID as string; + const adminUserIDInput = req.query.adminUserID as UserID; const enabled = req.query.enabled === undefined ? true @@ -27,9 +28,9 @@ export async function shadowBanUser(req: Request, res: Response): Promise 0; + const isVIP = await isUserVIP(adminUserID); if (!isVIP) { //not authorized return res.sendStatus(403); diff --git a/src/routes/voteOnSponsorTime.ts b/src/routes/voteOnSponsorTime.ts index a4c9628..02e8fbe 100644 --- a/src/routes/voteOnSponsorTime.ts +++ b/src/routes/voteOnSponsorTime.ts @@ -281,7 +281,7 @@ export async function voteOnSponsorTime(req: Request, res: Response): Promise 0; + const isVIP = await isUserVIP(nonAnonUserID); //check if user voting on own submission const isOwnSubmission = (await db.prepare("get", `SELECT "UUID" as "submissionCount" FROM "sponsorTimes" where "userID" = ? AND "UUID" = ?`, [nonAnonUserID, UUID])) !== undefined;