From 690347e7eaa21eb91aa463e3595cf731fce61421 Mon Sep 17 00:00:00 2001 From: whekin Date: Wed, 11 Mar 2026 11:26:16 +0400 Subject: [PATCH] fix(bot): expire pending payment topic actions --- apps/bot/src/payment-topic-ingestion.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/bot/src/payment-topic-ingestion.ts b/apps/bot/src/payment-topic-ingestion.ts index 04e00d8..7b98de1 100644 --- a/apps/bot/src/payment-topic-ingestion.ts +++ b/apps/bot/src/payment-topic-ingestion.ts @@ -1,6 +1,6 @@ import type { FinanceCommandService, PaymentConfirmationService } from '@household/application' import { Money } from '@household/domain' -import { instantFromEpochSeconds, type Instant } from '@household/domain' +import { instantFromEpochSeconds, nowInstant, type Instant } from '@household/domain' import type { Bot, Context } from 'grammy' import type { Logger } from '@household/observability' import type { @@ -20,6 +20,7 @@ const PAYMENT_TOPIC_CONFIRM_CALLBACK_PREFIX = 'payment_topic:confirm:' const PAYMENT_TOPIC_CANCEL_CALLBACK_PREFIX = 'payment_topic:cancel:' const PAYMENT_TOPIC_CLARIFICATION_ACTION = 'payment_topic_clarification' as const const PAYMENT_TOPIC_CONFIRMATION_ACTION = 'payment_topic_confirmation' as const +const PAYMENT_TOPIC_ACTION_TTL_MS = 30 * 60_000 export interface PaymentTopicCandidate { updateId: number @@ -472,7 +473,7 @@ export function registerConfiguredPaymentTopicIngestion( threadId: record.threadId, rawText: combinedText }, - expiresAt: null + expiresAt: nowInstant().add({ milliseconds: PAYMENT_TOPIC_ACTION_TTL_MS }) }) await replyToPaymentMessage(ctx, t.clarification) @@ -510,7 +511,7 @@ export function registerConfiguredPaymentTopicIngestion( telegramUpdateId: String(record.updateId), attachmentCount: record.attachmentCount }, - expiresAt: null + expiresAt: nowInstant().add({ milliseconds: PAYMENT_TOPIC_ACTION_TTL_MS }) }) await replyToPaymentMessage(