fix: stop the 5am notification storm - toggles off by default, plus change detection #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/notification-storm"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stops the 5am message storm, and fixes the reason it happened.
What happened
The billing sync rewrites every appointment in the active window on a schedule, and
handleWebhookcallednotifyAppointmenton every row it received - whether or not anything had actually changed. So a re-sync DM'd each tech their entire upcoming week, at 05:00 local.Confirmed from the KV store. Counting appointment records by the hour they were last written:
Bulk writes at 09:00 UTC, every Sunday, plus today. This has been happening all along - it only became audible when the TechMap was populated and the DMs finally had somewhere to go.
Immediate mitigation already applied
dispatch-botis disabled in production, which stops every DM path without touching the TechMap or the board. The own-column-first ordering people like is unaffected.Note this is a stopgap, not a fix:
OnActivatecallsEnsureBotUser, so a plugin restart or redeploy may well re-enable the bot. This PR needs to land before the next deploy, or the storm comes back on its own.Changes
Three toggles, all defaulting OFF (
plugin.json,server/plugin.go,server/notify.go):NotifyNewAppointmentNotifyChangesNotifyRemindersDefaulting off means the deploy itself is the fix - nothing to remember to switch off afterwards.
Change detection (
server/store.go,server/api.go) - the part that makes these safe to ever turn back on:apptFingerprint()hashes the fields a human would notice, deliberately ignoringUpdatedAt(rewritten on every save) andAction.handleWebhooknow reads the stored record before writing and skips the DM when the fingerprint is unchanged. Cancellation only notifies if it was not already cancelled.The board still updates on every webhook exactly as before - only the DM is gated.
Deliberately not done
No quiet hours. With reminders off by default it is not urgent, and I did not want to guess your working hours. Worth adding before
NotifyRemindersis ever switched on: a 06:00 appointment still means a 05:30 message, and that is a smaller version of this same problem.Verification
Version bumped to 0.2.1 so this build is distinguishable from what is running - the exact ambiguity that hid Phase 6 for a month.