Extend SHUTDOWN_MODE to block cron-driven notifications#21
Merged
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SHUTDOWN_MODEalready short-circuits incoming updates via the middleware insrc/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.isShutdownMode()helper insrc/helpers/isShutdownMode.ts, reused from the middleware and from each notification path.sendTriggeredAlert(src/cron/priceChecker/priceChecker.utils.ts) andcheckTriggeredShiftsAndSendMessage(src/cron/shiftsChecker/shiftChecker.utils.ts). The guard sits before any cache or DB mutation, so whenSHUTDOWN_MODEis later removed the alert state is intact..env.sampleandCONFIG.mdto 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 whenSHUTDOWN_MODE=true, proceeds when unset)src/cron/shiftsChecker/shiftChecker.utils.test.ts(short-circuits before percent math when on)npm run lintnpm run build