Skip to content

Commit 6ee13bf

Browse files
committed
ip rate limit
1 parent 2e8d14d commit 6ee13bf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/routes/conversation/[id]/+server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export async function POST({ request, fetch, locals, params, getClientAddress })
4646
throw error(429, "Exceeded number of messages before login");
4747
}
4848

49-
const nEvents = await collections.messageEvents.countDocuments({ userId });
49+
const nEvents = Math.max(
50+
await collections.messageEvents.countDocuments({ userId }),
51+
await collections.messageEvents.countDocuments({ ip: getClientAddress() })
52+
);
5053

5154
if (RATE_LIMIT != "" && nEvents > parseInt(RATE_LIMIT)) {
5255
throw error(429, ERROR_MESSAGES.rateLimited);

0 commit comments

Comments
 (0)