fix(botid): re-add bot protection to demo branch (#1445)

This commit is contained in:
dancer 2026-03-04 19:20:57 +00:00 committed by GitHub
parent 99cd8699c1
commit 3bc77653ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 45 additions and 11 deletions

View file

@ -3,8 +3,8 @@ import { createClient } from "redis";
import { isProductionEnvironment } from "@/lib/constants";
import { ChatbotError } from "@/lib/errors";
const MAX_MESSAGES_PER_DAY = 10;
const TTL_SECONDS = 60 * 60 * 24;
const MAX_MESSAGES = 10;
const TTL_SECONDS = 60 * 60;
let client: ReturnType<typeof createClient> | null = null;
@ -37,7 +37,7 @@ export async function checkIpRateLimit(ip: string | undefined) {
.expire(key, TTL_SECONDS, "NX")
.exec();
if (typeof count === "number" && count > MAX_MESSAGES_PER_DAY) {
if (typeof count === "number" && count > MAX_MESSAGES) {
throw new ChatbotError("rate_limit:chat");
}
} catch (error) {