Commit

4fa69ba

Lesson learned building mybirth.day: a surprise has to be revealed exactly once, even when two things try at the same moment. A surprise party stops being secret in one of two ways. The host taps "Reveal now", or it reveals itself when the party starts, from a command that runs every hour. A host standing in the middle of the party they organised isn't going to remember a button. So both can fire for the same event in the same minute. The fix is one conditional UPDATE: set revealed_at where the event is still sealed and revealed_at is null. Zero rows affected means somebody got there first, and that caller returns false. Only the winner sends notifications. The same claim makes the hourly command safe to re-run, or to overlap with itself. The honoree is told first, on their own, then everyone who said Going or Maybe. Known tradeoff: the claim happens before the sends, so a crash in between drops the announcements. The reveal itself stands, which is the half that matters. If that ever bites, it moves into a job. Cancelled surprises are skipped and stay sealed. Cancelling must not be how someone finds out there was going to be a party for them. mybirth.day/get

commit 4fa69ba