From e7bcdbf17e6611dee438ead4669e75771f5b4011 Mon Sep 17 00:00:00 2001 From: brobert Date: Sun, 9 Nov 2025 22:16:20 +0100 Subject: [PATCH] fix: ajustar tipado en proxy.ts, response-queue.ts y tasks/service.ts Co-authored-by: aider (openrouter/openai/gpt-5) --- proxy.ts | 4 +++- src/services/response-queue.ts | 10 +++++++--- src/tasks/service.ts | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/proxy.ts b/proxy.ts index 9489f4b..48d33a2 100644 --- a/proxy.ts +++ b/proxy.ts @@ -41,9 +41,11 @@ Bun.serve({ const init: RequestInit = { method: req.method, headers, - body: req.method === 'GET' || req.method === 'HEAD' ? undefined : req.body, redirect: 'manual', }; + if (req.method !== 'GET' && req.method !== 'HEAD' && req.body !== null) { + (init as any).body = req.body as any; + } const started = Date.now(); try { diff --git a/src/services/response-queue.ts b/src/services/response-queue.ts index 8acbaca..05f7077 100644 --- a/src/services/response-queue.ts +++ b/src/services/response-queue.ts @@ -147,7 +147,7 @@ export const ResponseQueue = { // Estadísticas de onboarding por destinatario (consulta simple sobre response_queue) getOnboardingStats(recipient: string): { total: number; lastSentAt: string | null; firstInitialAt?: string | null; lastVariant?: 'initial' | 'reminder' | null } { - if (!recipient) return { total: 0, lastSentAt: null, firstInitialAt: undefined, lastVariant: null }; + if (!recipient) return { total: 0, lastSentAt: null, lastVariant: null }; const rows = this.dbInstance.prepare(` SELECT status, created_at, updated_at, metadata FROM response_queue @@ -196,7 +196,11 @@ export const ResponseQueue = { } } - return { total, lastSentAt, firstInitialAt, lastVariant }; + const result: { total: number; lastSentAt: string | null; firstInitialAt?: string | null; lastVariant?: 'initial' | 'reminder' | null } = { total, lastSentAt, lastVariant }; + if (typeof firstInitialAt !== 'undefined') { + result.firstInitialAt = firstInitialAt; + } + return result; }, // Encolar una reacción con idempotencia (24h) usando metadata canónica @@ -647,7 +651,7 @@ export const ResponseQueue = { const interval = this.CLEANUP_INTERVAL_MS; this._cleanupTimer = setInterval(() => { - this.runCleanupOnce().catch(err => console.error('Scheduled cleanup error:', err)); + this.runCleanupOnce().catch((err: unknown) => console.error('Scheduled cleanup error:', err)); }, interval); console.log(`🗓️ Cleanup scheduler started (every ${Math.round(interval / (60 * 60 * 1000))}h)`); diff --git a/src/tasks/service.ts b/src/tasks/service.ts index 3fd7972..86c941c 100644 --- a/src/tasks/service.ts +++ b/src/tasks/service.ts @@ -328,7 +328,10 @@ export class TaskService { // Encolar reacción ✅ con idempotencia; no bloquear si falla const participant = origin && origin.participant ? String(origin.participant) : undefined; const fromMe = (origin && (origin.from_me === 1 || origin.from_me === true)) ? true : undefined; - ResponseQueue.enqueueReaction(chatId, String(origin.message_id), '✅', { participant, fromMe }) + const rxOpts: { participant?: string; fromMe?: boolean } = {}; + if (participant !== undefined) rxOpts.participant = participant; + if (typeof fromMe === 'boolean') rxOpts.fromMe = fromMe; + ResponseQueue.enqueueReaction(chatId, String(origin.message_id), '✅', rxOpts) .catch(() => {}); } }