fix(botid): re-add bot protection to demo branch (#1445)
This commit is contained in:
parent
99cd8699c1
commit
3bc77653ad
7 changed files with 45 additions and 11 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue