1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-20 09:41:35 +02:00

Implemented proposal described in the issue #1122

This commit is contained in:
aintDatCap 2024-07-24 19:06:12 +02:00
parent d3ece937e6
commit 5a20924477
2 changed files with 9 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import {
} from "@spacebar/util"; } from "@spacebar/util";
import { Request, Response, Router } from "express"; import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server"; import { HTTPError } from "lambert-server";
import { Config } from "@spacebar/util";
const router: Router = Router(); const router: Router = Router();
@ -52,7 +53,9 @@ router.post(
const userIds: Array<string> = req.body.user_ids; const userIds: Array<string> = req.body.user_ids;
if (!userIds) throw new HTTPError("The user_ids array is missing", 400); if (!userIds) throw new HTTPError("The user_ids array is missing", 400);
if (userIds.length > 200)
const bulkBanLimit = Config.get().limits.absoluteRate.bulkBan;
if (bulkBanLimit.enabled && userIds.length > bulkBanLimit.limit)
throw new HTTPError( throw new HTTPError(
"The user_ids array must be between 1 and 200 in length", "The user_ids array must be between 1 and 200 in length",
400, 400,

View File

@ -27,6 +27,11 @@ export class GlobalRateLimits {
window: 60 * 1000, window: 60 * 1000,
enabled: true, enabled: true,
}; };
bulkBan: GlobalRateLimit = {
limit: 200,
window: 0,
enabled: true,
};
} }
export class GlobalRateLimit { export class GlobalRateLimit {