(ctx context.Context, flags *RootFlags)
| 24 | } |
| 25 | |
| 26 | func (c *GmailForwardCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 27 | u := ui.FromContext(ctx) |
| 28 | |
| 29 | messageID := normalizeGmailMessageID(c.MessageID) |
| 30 | if messageID == "" { |
| 31 | return usage("required: messageId") |
| 32 | } |
| 33 | |
| 34 | note, err := resolveBodyInput(ctx, c.Note, c.NoteFile) |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | toRecipients := splitCSV(c.To) |
| 40 | if len(toRecipients) == 0 { |
| 41 | return usage("required: --to") |
| 42 | } |
| 43 | |
| 44 | if dryRunErr := dryRunExit(ctx, flags, "gmail.forward", map[string]any{ |
| 45 | "message_id": messageID, |
| 46 | "to": toRecipients, |
| 47 | "cc": splitCSV(c.Cc), |
| 48 | "bcc": splitCSV(c.Bcc), |
| 49 | "from": strings.TrimSpace(c.From), |
| 50 | "note_len": len(strings.TrimSpace(note)), |
| 51 | "skip_attachments": c.SkipAttachments, |
| 52 | }); dryRunErr != nil { |
| 53 | return dryRunErr |
| 54 | } |
| 55 | |
| 56 | account, svc, err := requireGmailSendService(ctx, flags) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | |
| 61 | from, err := resolveComposeSender(ctx, svc, account, c.From) |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | |
| 66 | // Fetch the original message in full format (headers + body + attachment metadata). |
| 67 | origMsg, err := svc.Users.Messages.Get("me", messageID).Format(gmailFormatFull).Context(ctx).Do() |
| 68 | if err != nil { |
| 69 | return fmt.Errorf("fetch original message: %w", err) |
| 70 | } |
| 71 | |
| 72 | origFrom := headerValue(origMsg.Payload, "From") |
| 73 | origTo := headerValue(origMsg.Payload, "To") |
| 74 | origCc := headerValue(origMsg.Payload, "Cc") |
| 75 | origDate := headerValue(origMsg.Payload, "Date") |
| 76 | origSubject := headerValue(origMsg.Payload, "Subject") |
| 77 | origPlain := gmailcontent.FindPartBody(origMsg.Payload, "text/plain") |
| 78 | origHTML := gmailcontent.FindPartBody(origMsg.Payload, "text/html") |
| 79 | |
| 80 | // Build forward subject (avoid stacking prefixes). |
| 81 | fwdSubject := buildForwardSubject(origSubject) |
| 82 | |
| 83 | // Resolve the timezone for the forwarded Date header from the same |
nothing calls this directly
no test coverage detected