summary refs log tree commit diff
diff options
context:
space:
mode:
authorErkin Alp Güney <erkinalp9035@gmail.com>2022-04-24 23:04:55 +0300
committerGitHub <noreply@github.com>2022-04-24 23:04:55 +0300
commit4871513640d49845edb8d22afbb8b8c3ed20a6e2 (patch)
tree16c1a0b4faf287e8010d602a214a9c33f8297c4e
parentUpdate Token.ts (diff)
downloadserver-4871513640d49845edb8d22afbb8b8c3ed20a6e2.tar.xz
Update RateLimit.ts
-rw-r--r--api/src/middlewares/RateLimit.ts5
1 files changed, 3 insertions, 2 deletions
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);