worker: Telegram notice about every purchase (notify task)
A separate worker task, apart from invoicing: each paid checkout is
announced once to the operator's Telegram chat ('Páros csomag, 6 000 Ft',
marked when it was a test payment), without the buyer's data. Outages
and rate limits are retried; a wrong token or chat is logged, not
retried. Needs TELEGRAM_BOT_TOKEN (.env.secrets) and TELEGRAM_CHAT_ID.
Also fixes the worker test that still expected the old sign-up e-mail
subject (CI failed on it since 7d6a6c3).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -20,7 +20,9 @@ mod compare;
|
||||
mod config;
|
||||
mod email;
|
||||
mod invoices;
|
||||
mod notify;
|
||||
mod ses;
|
||||
mod telegram;
|
||||
mod templates {
|
||||
pub use email_templates::*;
|
||||
}
|
||||
@@ -153,6 +155,15 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
None => tracing::warn!("BILLINGO_API_KEY is not set: invoices stay pending"),
|
||||
}
|
||||
match (&config.telegram_bot_token, &config.telegram_chat_id) {
|
||||
_ if !tasks.notify => {}
|
||||
(Some(token), Some(chat)) => {
|
||||
tracing::info!("purchase notices enabled (Telegram)");
|
||||
let telegram = telegram::Telegram::new(&config.telegram_api_url, token, chat);
|
||||
jobs.spawn(notify::run(pool.clone(), telegram, config.poll_interval, stop.clone()));
|
||||
}
|
||||
_ => tracing::info!("TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set: no purchase notices"),
|
||||
}
|
||||
|
||||
let app = Router::new().route("/healthz", get(healthz)).with_state(pool);
|
||||
let listener = tokio::net::TcpListener::bind(addr).await.with_context(|| format!("binding {addr}"))?;
|
||||
|
||||
Reference in New Issue
Block a user