Repository navigation
Email webchat visitors messages they didn't read - #6
Merged
Merged
Conversation
…rsation goes quiet
Review summaryThe design looks solid: claiming is atomic, so only one sweeper emails a conversation, and a crash loses an email rather than sending it twice. Errors are split into retryable and permanent, a failure to hold a message never fails the send, and the sweeper re-checks the channel config, the contact and the read status when it sends. Main issues (inline):
Test gaps:
🤖 Generated with Claude Code |
…sage doesn't cut a retry's backoff short
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
Builds on #5. When a channel is configured for email and the contact has an address, chip holds back each message it delivers. Once the conversation has gone quiet, it emails the visitor the messages they still haven't read. Courier never sends email, and chip still only reads the platform's database.
Changes
web/internal.go,core/email/pending.go): after a successful publish,/wi/sendholds the message in valkey: the address, the message UUIDs, and when the oldest was held.emailmeans the contact no longer has one, so anything held back for them is dropped.core/email/sweeper.go,cmd/service.go): every instance runs one, ticking every 30s. Claiming a due conversation is one atomic script that also removes its state, so only one instance emails it. A crash mid-send loses that email rather than sending it twice.GetUnreadChatMsgsloads the batch, andLoadOrgsupplies the sender name and the timezone the email's times are shown in.Test plan
TestGetUnreadChatMsgs,TestLoadOrgTestSweeper:TestSendHoldsForEmail: held back when configured with an address; dropped by a send without one; not held when the publish failsgo test ./...passes in the devcontainer