Skip to content

Commit 2e8d14d

Browse files
committed
Revert "IP based rate limit"
This reverts commit 87c6937.
1 parent 87c6937 commit 2e8d14d

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

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

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

49-
if (RATE_LIMIT !== "") {
50-
let nEvents = 0;
51-
if (locals.user?._id) {
52-
// if logged in do rate limiting based on user id
53-
nEvents = await collections.messageEvents.countDocuments({ userId });
54-
} else {
55-
// do rate limiting based on session id but also ip address
56-
const nEventsIp = await collections.messageEvents.countDocuments({ ip: getClientAddress() });
57-
const nEventsSession = await collections.messageEvents.countDocuments({ userId });
58-
nEvents = Math.max(nEventsIp, nEventsSession);
59-
}
49+
const nEvents = await collections.messageEvents.countDocuments({ userId });
6050

61-
if (nEvents > parseInt(RATE_LIMIT)) {
62-
throw error(429, ERROR_MESSAGES.rateLimited);
63-
}
51+
if (RATE_LIMIT != "" && nEvents > parseInt(RATE_LIMIT)) {
52+
throw error(429, ERROR_MESSAGES.rateLimited);
6453
}
6554

6655
const model = models.find((m) => m.id === conv.model);

0 commit comments

Comments
 (0)