1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-26 04:03:03 +01:00

Update RateLimit.ts

This commit is contained in:
Erkin Alp Güney 2022-04-24 23:04:55 +03:00 committed by GitHub
parent 08097e157f
commit 4871513640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,8 +70,9 @@ export default function rateLimit(opts: {
if (offender.blocked) {
const global = bucket_id === "global";
reset = reset + opts.window * 1000; // each block violation pushes the expiry one full window further
offender.expires_at = offender.expires_at + opts.window * 1000;
// each block violation pushes the expiry one full window further
reset = new Date(reset.getTime() + opts.window * 1000);
offender.expires_at = new Date(offender.expires_at.getTime() + opts.window * 1000);
resetAfterMs = reset - Date.now();
resetAfterSec = Math.ceil(resetAfterMs / 1000);