feat(mail): add --attachment to send, drafts create and replies#13
Open
okuegow wants to merge 1 commit into
Open
feat(mail): add --attachment to send, drafts create and replies#13okuegow wants to merge 1 commit into
okuegow wants to merge 1 commit into
Conversation
mog could not attach files. Add a repeatable `--attachment <path>` flag to `mail send` and `mail drafts create`: each file becomes an inline base64 microsoft.graph.fileAttachment (typed payload struct), content type inferred from the extension (fallback application/octet-stream). Paths are validated up front with clear errors: empty path, missing file, directory, and files at/over Graph's 3 MB inline limit. Replies (`--reply-to-message-id`) also support attachments. The single-step /reply action cannot carry inline attachments, so the reply is built via createReply, then PATCH/attach/send. The quoted original is preserved: text replies pass the user's text as the createReply comment; HTML replies prepend the user's HTML before the quoted draft body. On a pre-send failure the orphaned draft is deleted (best effort); if sending fails the draft is kept and named in the error. Also fixes the existing non-attachment reply path, which set both `comment` and `message.body` (Graph wants one or the other, can 400): now comment for text, message.body for HTML. Tests cover buildAttachments (content-type, empty/missing/dir/oversize), the send + drafts-create payloads, and the reply flow end to end: call order createReply->patch->attach->send, the attachment/recipient payloads, HTML quote prepending, and the createReply/attach/send error paths incl. orphan-draft cleanup. README and --ai-help updated. Closes visionik#10
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.
Problem
mog couldn't attach files to outgoing mail —
mail sendandmail drafts createonly supported recipients, subject and body.Changes
--attachment <path>flag formail sendandmail drafts create. Each file becomes an inline base64microsoft.graph.fileAttachment(typed payload struct); content type is inferred from the extension (fallbackapplication/octet-stream).--reply-to-message-id) support attachments too. The single-step/replyaction can't carry inline attachments, so the reply is built viacreateReply(keeping the quoted original), thenPATCH(recipients; for HTML also the body), onePOST .../attachmentsper file, andPOST .../send. Text replies pass the user's text as thecreateReplycomment; HTML replies prepend the user's HTML before the quoted draft body. On a pre-send failure the orphaned draft is deleted (best effort); if sending fails the draft is kept and named in the error.commentandmessage.body(Graph wants one or the other and can return 400): nowcommentfor text,message.bodyfor HTML.Tests
buildAttachments: content-type inference, and empty/missing/directory/oversize rejection.mail sendandmail drafts createPOST payloads include the attachment (asserted via the mock client).createReply → patch → attach → send, attachment/recipient payloads, HTML quote prepending, and the createReply/attach/send error paths incl. orphan-draft cleanup.go build/go vet/go test ./...pass. README and--ai-helpupdated.Closes #10