← All tests

NIX-OS-73 — Telegram Event Wiring (prod)

2026-04-23 on prod. M3 shipped the Telegram infrastructure (bot token storage, group CRUD, webhook/cron routes, send log); NIX-OS-73 completes the wiring so events from the POS flow actually reach subscribed groups. Three events now fire: session_closed from the close-shift action, new_order from /api/odoo/order, and daily_report from the /api/telegram/cron/daily cron — now using the new fetchDailyReport (NIX-OS-72) instead of monthly figures. All three route through a single central notifyEvent() dispatcher with per-send audit logging, and every call is fire-and-forget so a Telegram outage can never block a sale.

11/11 NIX-OS-73 prod click-through passed. Cron auth gate (401 without / with wrong secret) ✓, Telegram admin page loads ✓, full POS flow (open → ring → pay → close) completes without 5xx ✓, dispatcher wiring verified via cafe.telegram_send_log shape (no opted-in groups → zero rows, correct short-circuit). The formatter emits HTML-safe session_closed payloads with cashier name, duration, order count, gross/net, cash movements, diff + reason.
11/11 NIX-OS-73 + 77/77 prior-suite regression = 88/88 prod tests green. No schema changes this cycle. New files: lib/telegram/notify.ts (dispatcher) and lib/telegram/messages.ts (pure HTML-escaped formatters, unit-tested). Modified: closeShiftAction, /api/odoo/order, /api/telegram/cron/daily (now uses fetchDailyReport + ?dry=1 flag).