From b2647bdeab3fe27b39da268e1a096582edfc0047 Mon Sep 17 00:00:00 2001 From: Meik Date: Tue, 7 Apr 2026 16:59:01 +0200 Subject: [PATCH] Separate AI credential cooldowns from button limits --- backend/server.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/backend/server.js b/backend/server.js index 4954129..7b55857 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1202,8 +1202,6 @@ function buildAIAutoCommentRateLimitStatus(profileNumber, settings = getAIAutoCo } const normalizedPostKey = sanitizeAIAutoCommentPostKey(options.postKey); - clearExpiredAIAutoCommentProfileCooldown(normalizedProfileNumber, now); - const nowIso = now.toISOString(); const minuteWindowStart = new Date(now.getTime() - (60 * 1000)).toISOString(); const hourWindowStart = new Date(now.getTime() - (60 * 60 * 1000)).toISOString(); @@ -1215,7 +1213,6 @@ function buildAIAutoCommentRateLimitStatus(profileNumber, settings = getAIAutoCo const usedBurst = getAIAutoCommentEventCountSince(normalizedProfileNumber, burstWindowStart, nowIso); const usedDay = getAIAutoCommentEventCountSince(normalizedProfileNumber, dayWindowStart, nowIso); const lastEvent = getAIAutoCommentLatestEvent(normalizedProfileNumber); - const profileState = getAIAutoCommentProfileState(normalizedProfileNumber); const activeHours = getAIAutoCommentActiveHoursState(settings, now); const samePostExempt = Boolean(normalizedPostKey && hasAIAutoCommentEventForPost(normalizedProfileNumber, normalizedPostKey)); @@ -1240,10 +1237,6 @@ function buildAIAutoCommentRateLimitStatus(profileNumber, settings = getAIAutoCo }); }; - if (profileState && profileState.cooldown_until) { - addBlockingCandidate('cooldown', profileState.cooldown_until); - } - if (activeHours.configured && !activeHours.active) { addBlockingCandidate('active_hours', activeHours.nextAllowedAt); } @@ -1309,8 +1302,8 @@ function buildAIAutoCommentRateLimitStatus(profileNumber, settings = getAIAutoCo blocked_reason: blockedReason, blocked_until: blockedUntil, same_post_exempt: samePostExempt, - cooldown_until: profileState?.cooldown_until || null, - cooldown_reason: profileState?.cooldown_reason || null, + cooldown_until: null, + cooldown_reason: null, usage: { minute: usedMinute, hour: usedHour, @@ -2701,6 +2694,7 @@ db.exec(` CREATE INDEX IF NOT EXISTS idx_ai_auto_comment_rate_limit_events_profile_post ON ai_auto_comment_rate_limit_events(profile_number, post_key); `); +db.prepare('DELETE FROM ai_auto_comment_rate_limit_profile_state').run(); ensureColumn('ai_credentials', 'is_active', 'is_active INTEGER DEFAULT 1'); ensureColumn('ai_credentials', 'priority', 'priority INTEGER DEFAULT 0'); ensureColumn('ai_credentials', 'base_url', 'base_url TEXT'); @@ -8205,14 +8199,6 @@ app.post('/api/ai/generate-comment', async (req, res) => { console.error(`Failed with credential ${credential.name}:`, error.message); lastError = error; const errorUpdate = updateCredentialUsageOnError(credential.id, error); - if (traceSource === AI_AUTO_COMMENT_SOURCE && normalizedProfileNumber && autoCommentRateLimitSettings.enabled) { - const cooldownDecision = getAIAutoCommentCooldownDecision(autoCommentRateLimitSettings, error); - if (cooldownDecision) { - setAIAutoCommentProfileCooldown(normalizedProfileNumber, cooldownDecision); - autoCommentRateLimitStatus = buildAIAutoCommentRateLimitStatus(normalizedProfileNumber, autoCommentRateLimitSettings); - autoCommentRateLimitGlobalStatus = buildAIAutoCommentRateLimitStatus(normalizedProfileNumber, autoCommentRateLimitSettings); - } - } credentialTimingDetails.push({ credentialId: credential.id, credentialName: credential.name,