feat(inbound): AttachmentDownloader for provider-hosted attachments#32
Open
mpge wants to merge 1 commit intofeat/inbound-email-orchestrationfrom
Open
feat(inbound): AttachmentDownloader for provider-hosted attachments#32mpge wants to merge 1 commit intofeat/inbound-email-orchestrationfrom
mpge wants to merge 1 commit intofeat/inbound-email-orchestrationfrom
Conversation
Ports the Go (escalated-go#35) and .NET (escalated-dotnet#29) reference
to Spring Boot. Closes the last gap in the Phase-5 inbound pipeline:
host apps now have a ready-to-wire worker for the Mailgun-style
provider-hosted attachments surfaced in
InboundEmailService.ProcessResult.pendingAttachmentDownloads.
AttachmentDownloader
- download(pending, ticketId, replyId?) — HTTP GET via JDK
HttpClient + persist via AttachmentStorage + new row on
AttachmentRepository.
- downloadAll continues past per-attachment failures so a bad URL
doesn't block the rest; returns Result per input (persisted or
error set).
- Options.maxBytes size cap (throws AttachmentTooLargeException);
Options.basicAuth for providers that gate URLs by API key.
- safeFilename uses Path.getFileName so "../../etc/passwd" becomes
"passwd" — crafted names can't escape the storage root.
- Response Content-Type fallback when the PendingAttachment's own
contentType is empty.
AttachmentStorage contract (put) + reference LocalFileAttachmentStorage
that writes to local FS with timestamp+nanos prefixing so concurrent
uploads with the same original name don't collide. Host apps with S3 /
GCS / Azure can implement AttachmentStorage themselves.
13 Mockito/AssertJ tests cover: happy path (ticket + reply attachable
targets), 404 throw + no-persist, oversize → AttachmentTooLargeException,
basic auth header encoding, missing URL guard, response Content-Type
fallback, safeFilename path-traversal + edge cases, downloadAll
partial-failure handling, LocalFileStorage write / null-root rejection /
unique path per call.
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 Go (escalated-go#35) and .NET (escalated-dotnet#29) reference to Spring Boot. Host apps now have a ready-to-wire worker for the Mailgun-style provider-hosted attachments surfaced in `InboundEmailService.ProcessResult.pendingAttachmentDownloads`.
Design
`AttachmentDownloader`
`AttachmentStorage` contract + reference `LocalFileAttachmentStorage` that writes to local FS with timestamp+nanos prefixing so concurrent uploads with the same original name don't collide. Host apps with S3 / GCS / Azure can implement `AttachmentStorage` themselves.
Tests
13 Mockito / AssertJ cases:
Uses a `StubResponse` implementing `HttpResponse<byte[]>` directly to avoid the ceremony of standing up MockWebServer for a unit test.
Stacked PR
Based on `feat/inbound-email-orchestration` (#29) so `PendingAttachment` + `ProcessResult` are available. Merge order: #26 → #27 → #28 → #29 → this PR.