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.
This commit is contained in:
Michilis
2025-12-09 00:20:36 +00:00
parent d1ede9ee8d
commit 0eb8a6c580

View File

@@ -604,17 +604,24 @@ class NotificationScheduler {
if (!this.bot) return; if (!this.bot) return;
try { 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( const message = messages.notifications.drawReminder(
reminderTime.value, reminderTime.value,
reminderTime.unit, reminderTime.unit,
drawTime, drawTime,
cycle.pot_total_sats currentPotSats
); );
await this.bot.sendMessage(group.groupId, message, { parse_mode: 'Markdown' }); await this.bot.sendMessage(group.groupId, message, { parse_mode: 'Markdown' });
logger.info('Sent draw reminder to group', { logger.info('Sent draw reminder to group', {
groupId: group.groupId, groupId: group.groupId,
reminderKey: formatReminderTime(reminderTime) reminderKey: formatReminderTime(reminderTime),
potSats: currentPotSats
}); });
} catch (error) { } catch (error) {
this.handleSendError(error, group.groupId); this.handleSendError(error, group.groupId);
@@ -633,15 +640,21 @@ class NotificationScheduler {
if (!this.bot) return; if (!this.bot) return;
try { 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( const message = messages.notifications.drawReminder(
reminderTime.value, reminderTime.value,
reminderTime.unit, reminderTime.unit,
drawTime, drawTime,
cycle.pot_total_sats currentPotSats
); );
await this.bot.sendMessage(user.telegramId, message, { parse_mode: 'Markdown' }); 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) { } catch (error) {
logger.error('Failed to send reminder to user', { telegramId: user.telegramId, error }); logger.error('Failed to send reminder to user', { telegramId: user.telegramId, error });
} }