← All tests

#37 — Telegram Groups & Shift Time Management (full epic · prod)

The full 3-part #37 spec (auto-link by code · repeating shift reminders · the Admin-vs-Shop notification taxonomy). Verified on lumiere-coffee.nixtech.app.

Gate 2 8/8 passed. One combined ship — nix-cafe b4fc18d + 77fd451, backend migration applied to prod.

A — Auto-link: tenant/shop get a tnt-tg-XXXXXX / shop-tg-XXXXXX code (backfilled for every tenant + shop). Add @nix_cafe_bot to a group and type /setadmin <code> (Main Admin group) or /setshop <code> (Shop group) — the bot links it, no chat ID needed. Plus /status, duplicate/invalid handling, and auto-deactivate when the bot is removed (my_chat_member).
B — Shift reminders: per-window Remind after + Repeat every on a new Settings → Store → Shift Management page; the reminder now repeats every N min until the session closes (was once) via an atomic claim-or-refresh upsert.
C — Notification taxonomy: two group tiers (Main Admin vs Shop), shop-aware routing (one dispatch reaches the shop’s group + tenant-wide admin), and new register-opened / payment / refund / cash-in-out events with ✅/❌ matched-vs-mismatched cash formats.
A1 ✓Notifications page shows the tenant /setadmin code + shop codes (copyable).
A2 ✓Webhook deployed + secret-gated (401 without the Telegram secret token).
C1 ✓Shop-aware routing: a register_opened event reaches both the Shop group AND the Main Admin group.
C2 ✓A different shop’s event does NOT leak to this Shop group (only the tenant-wide Admin matches).
B1 ✓Repeat-dedup upsert is atomic: first send → fires, too-soon → skips, past repeat_every → fires again.
B2 ✓Shift Management page renders + saves Remind after / Repeat every (DB-verified 3 / 9 min).
C3 ✓End-to-end: opening a real shift fired register_opened to both seeded groups (Shop + Admin), logged in telegram_send_log.
— ✓No 5xx across the run · 51/51 regression.

Part A — link a group with a code (Settings → Notifications)

Notifications page with the per-tenant + per-shop /setadmin /setshop codes
The bot card now shows the tenant /setadmin tnt-tg-… code and each shop’s /setshop shop-tg-… code with copy buttons — no manual chat-ID paste. Click to zoom.

Part B — Settings → Store → Shift Management

New Shift Management page with Remind-after and Repeat-every columns
The moved shift editor with the new Remind after (min) and Repeat every (min) columns that drive the repeating close-shift reminder.