Repository navigation
Email visitors who don't have the chat open almost straight away - #7
Merged
Merged
Conversation
|
I didn't find any correctness bugs. I traced the new due-time logic in
Minor (inline): a failed presence check now skips the hold entirely. It also costs an extra connection and round trip per send, which could go inside Test gap: nothing covers the The 5s sweep interval is fine: when nothing is due, each instance runs one |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
For a visitor who doesn't have the chat open, email is the conversation, so holding their messages back for 3 minutes only delays the reply. Chip now emails them within about 15 seconds. Visitors with the chat open still get the 3-minute wait, since they may be reading along.
A chat's presence key has no unsubscribe callback. It lapses 150s after the last subscription refresh, so a visitor without it has already been gone a while. That signal carries its own delay, which is why chip doesn't need to wait much longer on top of it.
Changes
core/email/pending.go: the hold script checks the chat's presence key, the same one publishing checks. It does this atomically with the hold, so there's no extra round trip and no separate failure that could skip it.core/email/sweeper.go: the sweeper ticks every 5s instead of 30s, since the tick sets how late a fast email can be. Each tick is oneZRANGEBYSCOREwhen nothing is due.Behavior
Test plan
TestSendHoldsForEmail: due in 10s with no subscriber, 3m with oneTestSweeper:go test ./...passes in the devcontainer