From 0ec4a993223ac7b21a24afa6622eab7cdc019982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 21 May 2026 11:58:36 +0200 Subject: [PATCH] chore(jobs): remove dead TELEGRAM_CLEANUP_QUEUE handler and registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The queue had a handler, registration, and worker binding but no producer anywhere in the codebase — zero boss.send calls and no cron schedule. The doc comment claimed the Telegram sender schedules cleanup but the sender never called boss.send. Strip the constant, the interface, the handler, the allQueues entry, and the worker bind. --- src/lib/jobs/reminder-worker.ts | 44 --------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/lib/jobs/reminder-worker.ts b/src/lib/jobs/reminder-worker.ts index 6c9b6540b..95743bfcb 100644 --- a/src/lib/jobs/reminder-worker.ts +++ b/src/lib/jobs/reminder-worker.ts @@ -161,7 +161,6 @@ const BMI_STATUS_CRON = "20 2 * * *"; // daily at 02:20 const MEDICATION_COMPLIANCE_STATUS_QUEUE = "insights-medication-compliance-status"; const MEDICATION_COMPLIANCE_STATUS_CRON = "25 2 * * *"; // daily at 02:25 -const TELEGRAM_CLEANUP_QUEUE = "telegram-message-cleanup"; const MOODLOG_SYNC_QUEUE = "moodlog-sync"; const MOODLOG_SYNC_CRON = "30 * * * *"; // every hour at :30 const DATA_BACKUP_QUEUE = "data-backup"; @@ -278,12 +277,6 @@ interface MedicationComplianceStatusPayload { triggeredAt: string; } -interface TelegramCleanupPayload { - userId: string; - chatId: string; - messageId: number; -} - interface MoodLogSyncPayload { triggeredAt: string; } @@ -1091,37 +1084,6 @@ async function handleMedicationComplianceStatusGenerate( ); } -/** - * Delete a Telegram message after a 24h delay. - * Scheduled by the Telegram sender when a notification is sent. - */ -async function handleTelegramCleanup(jobs: Job[]) { - await withBackgroundEvent("job.telegram_cleanup", async (evt) => { - const prisma = getWorkerPrisma(); - let deleted = 0; - for (const job of jobs) { - try { - const { userId, chatId, messageId } = job.data; - const user = await prisma.user.findFirst({ - where: { id: userId, telegramBotToken: { not: null } }, - select: { telegramBotToken: true }, - }); - if (user?.telegramBotToken) { - const botToken = decrypt(user.telegramBotToken); - await deleteMessage(botToken, chatId, messageId); - deleted++; - } - } catch (err) { - evt.addWarning(`Failed to delete message: ${err}`); - } - } - evt.setBackground({ - task_name: "job.telegram_cleanup", - result: { deleted, total: jobs.length }, - }); - }); -} - /** * Fallback polling for moodLog data. * Syncs mood entries for all users with moodLog enabled. @@ -1669,7 +1631,6 @@ export async function startReminderWorker() { PULSE_STATUS_QUEUE, BMI_STATUS_QUEUE, MEDICATION_COMPLIANCE_STATUS_QUEUE, - TELEGRAM_CLEANUP_QUEUE, MOODLOG_SYNC_QUEUE, DATA_BACKUP_QUEUE, RATE_LIMIT_CLEANUP_QUEUE, @@ -1829,11 +1790,6 @@ export async function startReminderWorker() { { localConcurrency: 1 }, handleMedicationComplianceStatusGenerate, ); - await boss.work( - TELEGRAM_CLEANUP_QUEUE, - { localConcurrency: 1 }, - handleTelegramCleanup, - ); await boss.work( MOODLOG_SYNC_QUEUE, { localConcurrency: 1 },