Default to America/Phoenix and email-alert once when the session expires
All checks were successful
Deploy / deploy (push) Successful in 25s
All checks were successful
Deploy / deploy (push) Successful in 25s
Phoenix doesn't observe DST, so schedule times stay meaningful year-round without needing a seasonal adjustment. notify.py reuses lunch-notifier's existing Gmail-SMTP-with-app-password pattern rather than adding a new notification channel. The alert fires exactly once per expiry (not on every failed scheduled run while it's down) via a dedupe flag in notify_state.json, reset the moment a fresh session is successfully imported. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6TgffxTvYhqxykAbVQg2v
This commit is contained in:
parent
48d8bac332
commit
3b08af7938
7 changed files with 111 additions and 10 deletions
30
CLAUDE.md
30
CLAUDE.md
|
|
@ -23,10 +23,10 @@ tool is confirmed working, so there's exactly one thing triggering runs.
|
|||
(`LOGIN_PASSWORD` env var, `hmac.compare_digest`) — this protects the
|
||||
*admin UI itself*, unrelated to the MassPrice/TCGplayer login below.
|
||||
Routes: `/` (Dashboard — rule cards with schedule editor), `/activity`
|
||||
(run history), and a small JSON API
|
||||
(run history), `/session` (login-session import), and a small JSON API
|
||||
(`/api/rules/refresh`, `/api/rules/<id>/schedule`,
|
||||
`/api/rules/<id>/run`) that the Dashboard's JS calls without full page
|
||||
reloads.
|
||||
`/api/rules/<id>/run`, `/api/session/import`) that the frontend JS
|
||||
calls without full page reloads.
|
||||
- **`scheduler.py`** — an in-process APScheduler `BackgroundScheduler`
|
||||
holding one `CronTrigger` job per `(rule, schedule entry)` pair,
|
||||
rebuilt from `schedules.json` on startup and whenever the webui saves
|
||||
|
|
@ -61,7 +61,8 @@ tool is confirmed working, so there's exactly one thing triggering runs.
|
|||
- **`storage.py`** — tiny JSON read/write helpers (temp-file +
|
||||
`os.replace`, so a crash mid-write can't corrupt state) for
|
||||
everything under `/data`: `schedules.json`, `auth_state.json`,
|
||||
`run_history.json` (bounded to the last 200 entries), `rules_cache.json`.
|
||||
`run_history.json` (bounded to the last 200 entries), `rules_cache.json`,
|
||||
`notify_state.json` (the session-expiry alert's send-once dedupe flag).
|
||||
- **`templates/` / `static/`** — a small, plain dark dashboard. This is
|
||||
a deliberately different, simpler visual identity than Arr Summary's
|
||||
teletext system — that design language is specific to that app, not a
|
||||
|
|
@ -119,6 +120,27 @@ The Dashboard shows a red banner (`_session_warning()` in `app.py`) when
|
|||
the most recent run/refresh failed specifically because of a missing/
|
||||
expired session, so this doesn't just look like "no rules found."
|
||||
|
||||
## Session-expiry email alert
|
||||
|
||||
**`notify.py`** — a thin Gmail-SMTP-with-app-password sender, the same
|
||||
pattern `lunch-notifier` already uses on this box (reused deliberately
|
||||
rather than adding a second notification channel). `GMAIL_USER`/
|
||||
`GMAIL_APP_PASSWORD` (a Gmail **app password**, not the real account
|
||||
password — Gmail blocks plain SMTP auth otherwise) and optional
|
||||
`ALERT_EMAIL` (defaults to `GMAIL_USER`). `send_alert()` is a best-effort
|
||||
no-op — returns `False` and just logs — if those env vars aren't set or
|
||||
the send fails, since a broken mail config shouldn't break automation.
|
||||
|
||||
Fires exactly **once** per expiry, not on every failed scheduled run
|
||||
while it's down: `automation._notify_session_expired_once()` is called
|
||||
from `_ensure_authenticated()` right before it raises, checks/sets a
|
||||
`session_expired_notified` flag in `notify_state.json`, and only sends
|
||||
if that flag isn't already set. The flag resets to `False` the moment
|
||||
`import_cookies()` successfully saves a fresh session, so the next
|
||||
expiry gets its own alert. The flag is only set `True` after a
|
||||
confirmed-sent email — if mail is misconfigured, every failing run keeps
|
||||
retrying the send rather than silently giving up after the first one.
|
||||
|
||||
## Local development
|
||||
|
||||
```bash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue