Skip to content

Extend SHUTDOWN_MODE to block cron-driven notifications#21

Merged
AlekShu merged 1 commit into
masterfrom
goose-cf08
May 25, 2026
Merged

Extend SHUTDOWN_MODE to block cron-driven notifications#21
AlekShu merged 1 commit into
masterfrom
goose-cf08

Conversation

@AlekShu
Copy link
Copy Markdown
Collaborator

@AlekShu AlekShu commented May 25, 2026

Summary

  • SHUTDOWN_MODE already short-circuits incoming updates via the middleware in src/middlewares/shutdownMode.ts, but the bot kept pushing outbound notifications from the cron jobs (priceChecker, shiftsChecker) — so users still got alerts while the bot was supposed to be shut down.
  • Extracted a single source of truth isShutdownMode() helper in src/helpers/isShutdownMode.ts, reused from the middleware and from each notification path.
  • Gated sendTriggeredAlert (src/cron/priceChecker/priceChecker.utils.ts) and checkTriggeredShiftsAndSendMessage (src/cron/shiftsChecker/shiftChecker.utils.ts). The guard sits before any cache or DB mutation, so when SHUTDOWN_MODE is later removed the alert state is intact.
  • Updated .env.sample and CONFIG.md to make it clear the flag now blocks outbound notifications too.

Test plan

  • npx jest — 13 suites / 69 tests passing, including new tests:
    • src/helpers/isShutdownMode.test.ts (4 cases: unset / "true" / non-canonical truthy spellings / empty string)
    • src/cron/priceChecker/priceChecker.utils.test.ts (skips when SHUTDOWN_MODE=true, proceeds when unset)
    • src/cron/shiftsChecker/shiftChecker.utils.test.ts (short-circuits before percent math when on)
  • npm run lint
  • npm run build

The kill switch already intercepted incoming updates, but the
priceChecker and shiftsChecker cron jobs kept pushing alerts to users.
Add an isShutdownMode() helper and gate sendTriggeredAlert and
checkTriggeredShiftsAndSendMessage so nothing reaches the user while
the flag is on. The gate sits before any cache or DB mutation so
alerts survive the freeze unchanged.
@AlekShu AlekShu merged commit aabc96b into master May 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant