feat(inbound): scaffold InboundMessage + InboundEmailParser + InboundEmailRouter#26
Open
mpge wants to merge 1 commit intofeat/email-service-wireupfrom
Open
feat(inbound): scaffold InboundMessage + InboundEmailParser + InboundEmailRouter#26mpge wants to merge 1 commit intofeat/email-service-wireupfrom
mpge wants to merge 1 commit intofeat/email-service-wireupfrom
Conversation
…EmailRouter Greenfield inbound-email foundation for Spring. Transport-agnostic DTO (InboundMessage), pluggable provider parser interface (InboundEmailParser), and the routing brain (InboundEmailRouter) that resolves an inbound email to an existing ticket via canonical Message-ID parsing + signed Reply-To verification. Mirrors the NestJS reference and the per-framework inbound-verify PRs plus the .NET greenfield router (#23). Resolution order (first match wins): 1. In-Reply-To parsed via MessageIdUtil — cold-start path, no DB lookup required. 2. References parsed via MessageIdUtil, each id in order. 3. Signed Reply-To on toEmail verified via MessageIdUtil. Survives clients that strip threading headers; forged signatures are rejected with a timing-safe HMAC comparison. 4. Subject line reference tag [{PREFIX}-...] — legacy. 10 Mockito tests verify every branch + the forged-signature rejection, the blank-secret skip, the null-message safeguard, and the candidateHeaderMessageIds helper. Follow-up PRs: - Per-provider parser implementations (Postmark, Mailgun, SES) - InboundEmailController (POST /escalated/webhook/email/inbound) - InboundEmailService (full process() orchestration)
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
Greenfield inbound-email foundation for Spring. Introduces:
InboundMessage— transport-agnostic record capturing a normalized inbound email (from, to, subject, bodies, threading headers, attachments).InboundEmailParser— pluggable interface for provider-specific webhook payload normalization (Postmark, Mailgun, SES, IMAP).InboundEmailRouter— the resolution brain that maps an inbound message to an existing ticket via canonical Message-ID parsing + signed Reply-To verification.Mirrors the NestJS reference and the per-framework inbound-verify PRs (Laravel #70, Rails #45, Django #42, Adonis #50, WordPress #33) + the greenfield .NET router (escalated-dotnet #23).
Resolution order
MessageIdUtil.parseTicketIdFromMessageId— cold-start path, no DB lookup required.MessageIdUtil, each id in order.toEmail(reply+{id}.{hmac8}@...) verified viaMessageIdUtil.verifyReplyTo. Forged signatures rejected with the timing-safe HMAC comparison.[{PREFIX}-...]) — legacy.Scope
Router + DTO + interface only. Follow-up PRs:
InboundEmailController—POST /escalated/webhook/email/inboundInboundEmailService— fullprocess()orchestration with threading / attachmentsDependencies
feat/email-service-wireup), which is stacked on feat(email): add MessageIdUtil for RFC 5322 threading + signed Reply-To #24 (feat/email-message-id). UsesMessageIdUtil+EscalatedProperties.Email. Merge order: feat(email): add MessageIdUtil for RFC 5322 threading + signed Reply-To #24 → feat(email): wire MessageIdUtil into EmailService outbound headers #25 → this PR.Test plan
candidateHeaderMessageIds: in-reply-to first, references aftercandidateHeaderMessageIds: empty headers yield none