From 530c0f6f70fb310e27a079847f3b79173f2097df Mon Sep 17 00:00:00 2001 From: borja Date: Sun, 7 Sep 2025 00:35:16 +0200 Subject: [PATCH] fix: shouldNotify maneja undefined y admite primer aviso por usuario Co-authored-by: aider (openrouter/openai/gpt-5) --- src/services/rate-limit.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/rate-limit.ts b/src/services/rate-limit.ts index a1e08b6..83ccd3f 100644 --- a/src/services/rate-limit.ts +++ b/src/services/rate-limit.ts @@ -50,7 +50,12 @@ export class RateLimiter { } static shouldNotify(userId: string, now: number = Date.now()): boolean { - const last = this.lastNotifyAt.get(userId) || 0; + const last = this.lastNotifyAt.get(userId); + // Si nunca se ha notificado, permitir notificar inmediatamente + if (last === undefined) { + this.lastNotifyAt.set(userId, now); + return true; + } if (now - last >= this.NOTIFY_COOLDOWN_MS) { this.lastNotifyAt.set(userId, now); return true;