From 44ffa40b6ca3d0bf89c0809816c981253dace39f Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 6 Jan 2022 14:15:50 -0500 Subject: [PATCH] Should not add full segments to db from shadowbanned users --- src/routes/postSkipSegments.ts | 6 +++++- test/cases/postSkipSegments.ts | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index 576cbed..3123beb 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -644,7 +644,11 @@ export async function postSkipSegments(req: Request, res: Response): Promise { const warnVideoID = "postSkip2"; const badInputVideoID = "dQw4w9WgXcQ"; const shadowBanVideoID = "postSkipBan"; + const shadowBanVideoID2 = "postSkipBan2"; const queryDatabase = (videoID: string) => db.prepare("get", `SELECT "startTime", "endTime", "votes", "userID", "locked", "category", "actionType" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID]); const queryDatabaseActionType = (videoID: string) => db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "actionType" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID]); @@ -1179,6 +1180,25 @@ describe("postSkipSegments", () => { .catch(err => done(err)); }); + it("Should not add full segments to database if user if shadowbanned", (done) => { + const videoID = shadowBanVideoID2; + postSkipSegmentParam({ + videoID, + startTime: 0, + endTime: 0, + category: "sponsor", + actionType: "full", + userID: banUser01 + }) + .then(async res => { + assert.strictEqual(res.status, 200); + const row = await db.prepare("get", `SELECT "startTime", "endTime", "shadowHidden", "userID" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID]); + assert.strictEqual(row, undefined); + done(); + }) + .catch(err => done(err)); + }); + it("Should return 400 if videoID is empty", (done) => { const videoID = null as string; postSkipSegmentParam({