diff --git a/src/routes/getSearchSegments.ts b/src/routes/getSearchSegments.ts index 4fd2d88..13780eb 100644 --- a/src/routes/getSearchSegments.ts +++ b/src/routes/getSearchSegments.ts @@ -76,14 +76,12 @@ async function handleGetSegments(req: Request, res: Response): Promise { } } catch (err) { /* istanbul ignore next */ - console.log(err) if (err instanceof SyntaxError) { return res.status(400).send("Invalid array in parameters"); } else return res.sendStatus(500); diff --git a/test/cases/shadowBanUser.ts b/test/cases/shadowBanUser.ts index dbe5297..9291cbe 100644 --- a/test/cases/shadowBanUser.ts +++ b/test/cases/shadowBanUser.ts @@ -32,9 +32,15 @@ describe("shadowBanUser", () => { await db.prepare("run", insertQuery, [video, 20, 10, 2, 0, "shadow-50", "shadowBanned5", 0, 50, "sponsor", "YouTube", 0, videohash]); + await db.prepare("run", insertQuery, [video, 10, 10, 2, 1, "shadow-60", "shadowBanned6", 0, 50, "sponsor", "YouTube", 0, videohash]); + await db.prepare("run", insertQuery, ["lockedVideo", 10, 10, 2, 1, "shadow-61", "shadowBanned6", 0, 50, "sponsor", "YouTube", 0, getHash("lockedVideo", 1)]); + await db.prepare("run", `INSERT INTO "shadowBannedUsers" ("userID") VALUES(?)`, ["shadowBanned3"]); await db.prepare("run", `INSERT INTO "shadowBannedUsers" ("userID") VALUES(?)`, ["shadowBanned4"]); + await db.prepare("run", `INSERT INTO "lockCategories" ("userID", "videoID", "actionType", "category", "service") VALUES (?, ?, ?, ?, ?)`, + [getHash("shadow-ban-vip", 1), "lockedVideo", "skip", "sponsor", "YouTube"]); + await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES(?)`, [getHash(VIPuserID)]); }); @@ -274,4 +280,30 @@ describe("shadowBanUser", () => { }) .catch(err => done(err)); }); + + it("Should exclude locked segments when shadowbanning and removing segments", (done) => { + const userID = "shadowBanned6"; + client({ + method: "POST", + url: endpoint, + params: { + userID, + adminUserID: VIPuserID, + enabled: true, + categories: `["sponsor"]`, + unHideOldSubmissions: true + } + }) + .then(async res => { + assert.strictEqual(res.status, 200); + const type1Videos = await getShadowBanSegmentCategory(userID, 2); + const type0Videos = await getShadowBanSegmentCategory(userID, 0); + const shadowRow = await getShadowBan(userID); + assert.ok(shadowRow); // ban exists + assert.strictEqual(type1Videos.length, 0); // no banned videos + assert.strictEqual(type0Videos.length, 1); // video still visible + done(); + }) + .catch(err => done(err)); + }); });