feat(api): forward inbound messages — /messages/{id}/forward across SDKs, CLI, MCP#171
Merged
Conversation
…CLI/MCP
Mirrors the existing reply path: handler validates ownership, applies
HITL/idempotency/rate-limit/domain checks, then composes via new
outbound.BuildForward{Subject,Body,HTMLBody} helpers — best-effort MIME
extraction of the original body, Gmail-style header block, no
In-Reply-To/References (forwards are new threads).
HITL fix: buildSendRequestFromMessage now only copies email_message_id
into ReplyToMessageID when type="reply", so approved forwards don't
accidentally stitch into the original thread on send.
Includes:
- migration 019 extending messages.message_type CHECK with 'forward'
- TS SDK forwardMessage in api/client/inbound-email
- CLI: e2a forward <msg-id> --to … [--body …]
- MCP: forward_message tool
- Compile fix on a pre-existing internal/e2e mismatch where local
structs declared To as string instead of []string
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ests
Review follow-ups:
1. BuildForwardBody mangled CRLF input. The naive ReplaceAll("\n","\r\n")
turned existing "\r\n" into "\r\r\n", which renders as a literal CR
in some clients. Most real inbound bodies arrive CRLF-terminated, so
the bug would fire on virtually every multi-line forward.
Fix: normalize "\r\n" → "\n" first, then convert to "\r\n".
2. performSelfSend hardcoded message_type="send" for the loopback row.
Pre-existing latent bug — self-replies also recorded as "send".
Fix: thread msgType through; all three callers (send/reply/forward)
now record their actual intent.
3. Add the 4 integration tests the review called out:
- TestForwardMessageSelfForwardUsesLoopback (loopback path coverage)
- TestForwardMessageHTMLAtSMTP (multipart/alternative at the wire)
- TestForwardMessageWithAttachments (caller-supplied attachment passthrough)
- TestForwardMessageIdempotentReplay (Idempotency-Key replay shape)
4. Add 2 CRLF regression tests on BuildForwardBody (both CRLF and LF-only
inputs must emit clean CRLF, never "\r\r\n").
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0dd179c to
cd50568
Compare
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
Adds a Forward endpoint mirroring the existing Reply path:
POST /api/v1/agents/{email}/messages/{id}/forward.Surfaces shipped
What's NOT in scope (deferred)
Test plan
Pre-existing failures NOT caused by this PR:
🤖 Generated with Claude Code