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:
@@ -99,7 +99,7 @@ async fn delivers_retries_and_gives_up(db: PgPool) {
|
||||
let d = delivery(db.clone(), vec![("flaky@example.com", false), ("rejected@example.com", true)]);
|
||||
|
||||
assert_eq!(d.deliver_due().await.unwrap(), 4);
|
||||
assert_eq!(sent(&d), vec![("anna@example.com".into(), "Erősítsd meg az e-mail-címed".into())]);
|
||||
assert_eq!(sent(&d), vec![("anna@example.com".into(), "Add meg a jelszavad".into())]);
|
||||
assert_eq!(state(&db, ok).await, (1, true, false, None, false));
|
||||
// Temporary failure: retried later, not at once.
|
||||
assert_eq!(state(&db, flaky).await, (1, false, false, Some("test failure".into()), true));
|
||||
@@ -228,12 +228,13 @@ async fn cleanup_removes_only_expired_data(db: PgPool) {
|
||||
fn worker_tasks_are_chosen_by_name() {
|
||||
use crate::config::Tasks;
|
||||
let mail = Tasks::parse("email, cleanup").unwrap();
|
||||
assert_eq!(mail, Tasks { email: true, cleanup: true, analyses: false, invoices: false });
|
||||
assert_eq!(mail, Tasks { email: true, cleanup: true, analyses: false, invoices: false, notify: false });
|
||||
assert_eq!(
|
||||
Tasks::parse("analyses").unwrap(),
|
||||
Tasks { email: false, cleanup: false, analyses: true, invoices: false }
|
||||
Tasks { email: false, cleanup: false, analyses: true, invoices: false, notify: false }
|
||||
);
|
||||
assert!(Tasks::parse("email,invoices").unwrap().invoices);
|
||||
assert!(Tasks::parse("email,cleanup,invoices,notify").unwrap().notify);
|
||||
assert!(Tasks::parse("emails").is_err());
|
||||
assert!(Tasks::parse(" , ").is_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user