Spaces:
Build error
Build error
ip rate limit
Browse files
src/routes/conversation/[id]/+server.ts
CHANGED
@@ -46,7 +46,10 @@ export async function POST({ request, fetch, locals, params, getClientAddress })
|
|
46 |
throw error(429, "Exceeded number of messages before login");
|
47 |
}
|
48 |
|
49 |
-
const nEvents =
|
|
|
|
|
|
|
50 |
|
51 |
if (RATE_LIMIT != "" && nEvents > parseInt(RATE_LIMIT)) {
|
52 |
throw error(429, ERROR_MESSAGES.rateLimited);
|
|
|
46 |
throw error(429, "Exceeded number of messages before login");
|
47 |
}
|
48 |
|
49 |
+
const nEvents = Math.max(
|
50 |
+
await collections.messageEvents.countDocuments({ userId }),
|
51 |
+
await collections.messageEvents.countDocuments({ ip: getClientAddress() })
|
52 |
+
);
|
53 |
|
54 |
if (RATE_LIMIT != "" && nEvents > parseInt(RATE_LIMIT)) {
|
55 |
throw error(429, ERROR_MESSAGES.rateLimited);
|