From 4871513640d49845edb8d22afbb8b8c3ed20a6e2 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 24 Apr 2022 23:04:55 +0300 Subject: Update RateLimit.ts --- api/src/middlewares/RateLimit.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'api/src/middlewares') diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts index f31aa5da..4bbef520 100644 --- a/api/src/middlewares/RateLimit.ts +++ b/api/src/middlewares/RateLimit.ts @@ -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); -- cgit 1.4.1