fix: ajustar tipado en proxy.ts, response-queue.ts y tasks/service.ts

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
main
brobert 1 month ago
parent f0038ed763
commit e7bcdbf17e

@ -41,9 +41,11 @@ Bun.serve({
const init: RequestInit = { const init: RequestInit = {
method: req.method, method: req.method,
headers, headers,
body: req.method === 'GET' || req.method === 'HEAD' ? undefined : req.body,
redirect: 'manual', redirect: 'manual',
}; };
if (req.method !== 'GET' && req.method !== 'HEAD' && req.body !== null) {
(init as any).body = req.body as any;
}
const started = Date.now(); const started = Date.now();
try { try {

@ -147,7 +147,7 @@ export const ResponseQueue = {
// Estadísticas de onboarding por destinatario (consulta simple sobre response_queue) // 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 } { 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(` const rows = this.dbInstance.prepare(`
SELECT status, created_at, updated_at, metadata SELECT status, created_at, updated_at, metadata
FROM response_queue 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 // Encolar una reacción con idempotencia (24h) usando metadata canónica
@ -647,7 +651,7 @@ export const ResponseQueue = {
const interval = this.CLEANUP_INTERVAL_MS; const interval = this.CLEANUP_INTERVAL_MS;
this._cleanupTimer = setInterval(() => { 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); }, interval);
console.log(`🗓️ Cleanup scheduler started (every ${Math.round(interval / (60 * 60 * 1000))}h)`); console.log(`🗓️ Cleanup scheduler started (every ${Math.round(interval / (60 * 60 * 1000))}h)`);

@ -328,7 +328,10 @@ export class TaskService {
// Encolar reacción ✅ con idempotencia; no bloquear si falla // Encolar reacción ✅ con idempotencia; no bloquear si falla
const participant = origin && origin.participant ? String(origin.participant) : undefined; const participant = origin && origin.participant ? String(origin.participant) : undefined;
const fromMe = (origin && (origin.from_me === 1 || origin.from_me === true)) ? true : 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(() => {}); .catch(() => {});
} }
} }

Loading…
Cancel
Save