From 0eb8a6c580bc03a07c27b27e22504571779c9c25 Mon Sep 17 00:00:00 2001 From: Michilis Date: Tue, 9 Dec 2025 00:20:36 +0000 Subject: [PATCH] Fix: Fetch fresh pot amount when sending draw reminders Reminders now fetch current cycle data instead of using cached data from when the reminder was scheduled, ensuring accurate pot amounts. --- .../src/services/notificationScheduler.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/telegram_bot/src/services/notificationScheduler.ts b/telegram_bot/src/services/notificationScheduler.ts index 8f98d8f..d87159d 100644 --- a/telegram_bot/src/services/notificationScheduler.ts +++ b/telegram_bot/src/services/notificationScheduler.ts @@ -604,17 +604,24 @@ class NotificationScheduler { if (!this.bot) return; try { + // Fetch fresh cycle data to get current pot amount + const freshJackpot = await apiClient.getNextJackpot(); + const currentPotSats = freshJackpot?.cycle?.id === cycle.id + ? freshJackpot.cycle.pot_total_sats + : cycle.pot_total_sats; + const message = messages.notifications.drawReminder( reminderTime.value, reminderTime.unit, drawTime, - cycle.pot_total_sats + currentPotSats ); await this.bot.sendMessage(group.groupId, message, { parse_mode: 'Markdown' }); logger.info('Sent draw reminder to group', { groupId: group.groupId, - reminderKey: formatReminderTime(reminderTime) + reminderKey: formatReminderTime(reminderTime), + potSats: currentPotSats }); } catch (error) { this.handleSendError(error, group.groupId); @@ -633,15 +640,21 @@ class NotificationScheduler { if (!this.bot) return; try { + // Fetch fresh cycle data to get current pot amount + const freshJackpot = await apiClient.getNextJackpot(); + const currentPotSats = freshJackpot?.cycle?.id === cycle.id + ? freshJackpot.cycle.pot_total_sats + : cycle.pot_total_sats; + const message = messages.notifications.drawReminder( reminderTime.value, reminderTime.unit, drawTime, - cycle.pot_total_sats + currentPotSats ); await this.bot.sendMessage(user.telegramId, message, { parse_mode: 'Markdown' }); - logger.info('Sent draw reminder to user', { telegramId: user.telegramId }); + logger.info('Sent draw reminder to user', { telegramId: user.telegramId, potSats: currentPotSats }); } catch (error) { logger.error('Failed to send reminder to user', { telegramId: user.telegramId, error }); }