feat(email): add MessageIdUtil for RFC 5322 threading + signed Reply-To#24
Open
feat(email): add MessageIdUtil for RFC 5322 threading + signed Reply-To#24
Conversation
Ports the NestJS email/message-id.ts helpers to Spring: - buildMessageId(ticketId, replyId, domain) — RFC 5322 Message-ID - parseTicketIdFromMessageId(raw) — inbound lookup - buildReplyTo(ticketId, secret, domain) — signed Reply-To for threading - verifyReplyTo(address, secret) — inbound webhook verification The signed Reply-To carries identity even when clients strip our Message-ID / In-Reply-To headers, so the inbound provider webhook can verify before routing a reply to its ticket. Pure functions, no Spring context — 13 unit tests covering round-trip, tamper rejection, case-insensitive hex, malformed input, and the local-part-only acceptance path. Follow-up PR will wire the util into EmailService so outbound ticket notifications use the RFC-compliant Message-ID + signed Reply-To, and add an EscalatedProperties.Email config block for domain+secret.
This was referenced Apr 24, 2026
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
Ports the NestJS
email/message-id.tshelpers to Spring. Pure utility class, no runtime dependencies beyond the JDK'sjavax.crypto.API
buildMessageId(ticketId, replyId, domain)— RFC 5322 Message-ID<ticket-{id}@{domain}>for initial ticket emails<ticket-{id}-reply-{replyId}@{domain}>for agent repliesparseTicketIdFromMessageId(raw)— extract ticket id from header value (accepts with or without angle brackets)buildReplyTo(ticketId, secret, domain)— signed Reply-To of the formreply+{id}.{hmac8}@{domain}verifyReplyTo(address, secret)— inbound webhook check; returns ticket id on matchWhy signed Reply-To
Even when clients strip our
Message-ID/In-Reply-Toheaders, the Reply-To address still carries ticket identity — the 8-char HMAC-SHA256 prefix prevents forgery.Scope
Utility only. Follow-up PR will:
MessageIdUtilintoEmailService.sendEmail(Message-ID + Reply-To headers)EscalatedProperties.Emailconfig block fordomain+inboundSecretverifyReplyToTest plan
test,checkstyle