Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions shortcuts/mail/mail_draft_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
{Name: "request-receipt", Type: "bool", Desc: "Request a read receipt (Message Disposition Notification, RFC 3798) addressed to the sender. Recipient mail clients may prompt the user, send automatically, or silently ignore — delivery of a receipt is not guaranteed."},
{Name: "template-id", Desc: "Optional. Apply a saved template by ID (decimal integer string) before composing. The template's subject/body/to/cc/bcc/attachments are merged with user-supplied flags (user flags win). Requires --as user."},
signatureFlag,
noSignatureFlag,
priorityFlag,
eventSummaryFlag, eventStartFlag, eventEndFlag, eventLocationFlag,
showLintDetailsFlag,
Expand Down Expand Up @@ -92,7 +93,7 @@
if !hasTemplate && strings.TrimSpace(runtime.Str("subject")) == "" {
return mailValidationParamError("--subject", "--subject is required; pass the final email subject (or use --template-id)")
}
if err := validateSignatureWithPlainText(runtime.Bool("plain-text"), runtime.Str("signature-id")); err != nil {
if err := validateSignatureFlags(runtime.Bool("no-signature"), runtime.Str("signature-id")); err != nil {
return err
}
if err := validateEventFlags(runtime); err != nil {
Expand Down Expand Up @@ -180,7 +181,11 @@
if strings.TrimSpace(input.Body) == "" {
return mailValidationParamError("--body", "effective body is empty after applying template; pass --body explicitly")
}
sigResult, err := resolveSignature(ctx, runtime, mailboxID, runtime.Str("signature-id"), runtime.Str("from"))
senderEmail := runtime.Str("from")
if senderEmail == "" && runtime.Str("mailbox") != "" && runtime.Str("mailbox") != "me" {
senderEmail = runtime.Str("mailbox")

Check warning on line 186 in shortcuts/mail/mail_draft_create.go

View check run for this annotation

Codecov / codecov/patch

shortcuts/mail/mail_draft_create.go#L186

Added line #L186 was not covered by tests
}
sigResult, err := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail, sigKindSend)
if err != nil {
return err
}
Expand Down Expand Up @@ -290,7 +295,7 @@
var composedHTMLBody string
var composedTextBody string
if input.PlainText {
composedTextBody = input.Body
composedTextBody = appendPlainTextSignature(input.Body, sigResult)
bld = bld.TextBody([]byte(composedTextBody))
} else if bodyIsHTML(input.Body) || sigResult != nil {
htmlBody := input.Body
Expand Down Expand Up @@ -335,7 +340,7 @@
return "", lintApplied, lintBlocked, cidErr
}
} else {
composedTextBody = input.Body
composedTextBody = appendPlainTextSignature(input.Body, sigResult)
bld = bld.TextBody([]byte(composedTextBody))
}
// Embed template SMALL non-inline attachments via AddAttachment. No-op
Expand Down
14 changes: 7 additions & 7 deletions shortcuts/mail/mail_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
{Name: "subject", Desc: "Optional. Override the auto-generated Fw: subject. When set, the shortcut uses this value verbatim instead of prefixing the original subject."},
{Name: "template-id", Desc: "Optional. Apply a saved template by ID (decimal integer string) before composing. The template's body/to/cc/bcc/attachments are merged into the forward draft (template values appended to user flags / forward-derived values; no de-duplication)."},
signatureFlag,
noSignatureFlag,
priorityFlag,
eventSummaryFlag, eventStartFlag, eventEndFlag, eventLocationFlag,
showLintDetailsFlag},
Expand Down Expand Up @@ -96,7 +97,7 @@
return err
}
}
if err := validateSignatureWithPlainText(runtime.Bool("plain-text"), runtime.Str("signature-id")); err != nil {
if err := validateSignatureFlags(runtime.Bool("no-signature"), runtime.Str("signature-id")); err != nil {
return err
}
if err := validateEventFlags(runtime); err != nil {
Expand Down Expand Up @@ -127,12 +128,7 @@
return err
}

signatureID := runtime.Str("signature-id")
mailboxID := resolveComposeMailboxID(runtime)
sigResult, sigErr := resolveSignature(ctx, runtime, mailboxID, signatureID, runtime.Str("from"))
if sigErr != nil {
return sigErr
}
sourceMsg, err := fetchComposeSourceMessage(runtime, mailboxID, messageId)
if err != nil {
return mailDecorateProblemMessage(err, "failed to fetch original message")
Expand All @@ -155,6 +151,10 @@
if senderEmail == "" {
senderEmail = orig.headTo
}
sigResult, sigErr := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail, sigKindSend)
if sigErr != nil {
return sigErr

Check warning on line 156 in shortcuts/mail/mail_forward.go

View check run for this annotation

Codecov / codecov/patch

shortcuts/mail/mail_forward.go#L156

Added line #L156 was not covered by tests
}

// --template-id merge (§5.5 Q1-Q5).
var templateLargeAttachmentIDs []string
Expand Down Expand Up @@ -310,7 +310,7 @@
return err
}
} else {
composedTextBody = buildForwardedMessage(&orig, body)
composedTextBody = buildForwardedMessage(&orig, appendPlainTextSignature(body, sigResult))
bld = bld.TextBody([]byte(composedTextBody))
}
// Embed template SMALL non-inline attachments regardless of body mode.
Expand Down
14 changes: 7 additions & 7 deletions shortcuts/mail/mail_reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
{Name: "subject", Desc: "Optional. Override the auto-generated Re: subject. When set, the shortcut uses this value verbatim instead of prefixing the original subject."},
{Name: "template-id", Desc: "Optional. Apply a saved template by ID (decimal integer string) before composing. The template's body/to/cc/bcc/attachments are appended to the reply-derived values (no de-duplication; see warning in Execute output)."},
signatureFlag,
noSignatureFlag,
priorityFlag,
eventSummaryFlag, eventStartFlag, eventEndFlag, eventLocationFlag,
showLintDetailsFlag},
Expand Down Expand Up @@ -93,7 +94,7 @@
if err := validateSendTime(runtime); err != nil {
return err
}
if err := validateSignatureWithPlainText(runtime.Bool("plain-text"), runtime.Str("signature-id")); err != nil {
if err := validateSignatureFlags(runtime.Bool("no-signature"), runtime.Str("signature-id")); err != nil {
return err
}
if err := validateEventFlags(runtime); err != nil {
Expand Down Expand Up @@ -129,12 +130,7 @@
return err
}

signatureID := runtime.Str("signature-id")
mailboxID := resolveComposeMailboxID(runtime)
sigResult, sigErr := resolveSignature(ctx, runtime, mailboxID, signatureID, runtime.Str("from"))
if sigErr != nil {
return sigErr
}
sourceMsg, err := fetchComposeSourceMessage(runtime, mailboxID, messageId)
if err != nil {
return mailDecorateProblemMessage(err, "failed to fetch original message")
Expand All @@ -155,6 +151,10 @@
if senderEmail == "" {
senderEmail = orig.headTo
}
sigResult, sigErr := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail, sigKindReply)
if sigErr != nil {
return sigErr

Check warning on line 156 in shortcuts/mail/mail_reply.go

View check run for this annotation

Codecov / codecov/patch

shortcuts/mail/mail_reply.go#L156

Added line #L156 was not covered by tests
}

replyTo := orig.replyTo
if replyTo == "" {
Expand Down Expand Up @@ -311,7 +311,7 @@
return err
}
} else {
composedTextBody = bodyStr + quoted
composedTextBody = appendPlainTextSignature(bodyStr, sigResult) + quoted
bld = bld.TextBody([]byte(composedTextBody))
}
// Embed template SMALL non-inline attachments regardless of body mode.
Expand Down
14 changes: 7 additions & 7 deletions shortcuts/mail/mail_reply_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
{Name: "subject", Desc: "Optional. Override the auto-generated Re: subject. When set, the shortcut uses this value verbatim instead of prefixing the original subject."},
{Name: "template-id", Desc: "Optional. Apply a saved template by ID (decimal integer string) before composing. The template's body/to/cc/bcc/attachments are appended to the reply-derived values (no de-duplication; see warning in Execute output)."},
signatureFlag,
noSignatureFlag,
priorityFlag,
eventSummaryFlag, eventStartFlag, eventEndFlag, eventLocationFlag,
showLintDetailsFlag},
Expand Down Expand Up @@ -94,7 +95,7 @@
if err := validateSendTime(runtime); err != nil {
return err
}
if err := validateSignatureWithPlainText(runtime.Bool("plain-text"), runtime.Str("signature-id")); err != nil {
if err := validateSignatureFlags(runtime.Bool("no-signature"), runtime.Str("signature-id")); err != nil {
return err
}
if err := validateEventFlags(runtime); err != nil {
Expand Down Expand Up @@ -131,12 +132,7 @@
return err
}

signatureID := runtime.Str("signature-id")
mailboxID := resolveComposeMailboxID(runtime)
sigResult, sigErr := resolveSignature(ctx, runtime, mailboxID, signatureID, runtime.Str("from"))
if sigErr != nil {
return sigErr
}
sourceMsg, err := fetchComposeSourceMessage(runtime, mailboxID, messageId)
if err != nil {
return mailDecorateProblemMessage(err, "failed to fetch original message")
Expand All @@ -157,6 +153,10 @@
if senderEmail == "" {
senderEmail = orig.headTo
}
sigResult, sigErr := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail, sigKindReply)
if sigErr != nil {
return sigErr

Check warning on line 158 in shortcuts/mail/mail_reply_all.go

View check run for this annotation

Codecov / codecov/patch

shortcuts/mail/mail_reply_all.go#L158

Added line #L158 was not covered by tests
}

var removeList []string
for _, r := range strings.Split(removeFlag, ",") {
Expand Down Expand Up @@ -316,7 +316,7 @@
return err
}
} else {
composedTextBody = bodyStr + quoted
composedTextBody = appendPlainTextSignature(bodyStr, sigResult) + quoted
bld = bld.TextBody([]byte(composedTextBody))
}
// Embed template SMALL non-inline attachments regardless of body mode.
Expand Down
10 changes: 5 additions & 5 deletions shortcuts/mail/mail_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{Name: "request-receipt", Type: "bool", Desc: "Request a read receipt (Message Disposition Notification, RFC 3798) addressed to the sender. Recipient mail clients may prompt the user, send automatically, or silently ignore — delivery of a receipt is not guaranteed."},
{Name: "template-id", Desc: "Optional. Apply a saved template by ID (decimal integer string) before composing. The template's subject/body/to/cc/bcc/attachments are merged with user-supplied flags (user flags win). Requires --as user."},
signatureFlag,
noSignatureFlag,
priorityFlag,
eventSummaryFlag, eventStartFlag, eventEndFlag, eventLocationFlag,
showLintDetailsFlag},
Expand Down Expand Up @@ -98,7 +99,7 @@
if err := validateSendTime(runtime); err != nil {
return err
}
if err := validateSignatureWithPlainText(runtime.Bool("plain-text"), runtime.Str("signature-id")); err != nil {
if err := validateSignatureFlags(runtime.Bool("no-signature"), runtime.Str("signature-id")); err != nil {
return err
}
// Resolve the body content first (reading --body-file if set) so
Expand Down Expand Up @@ -137,7 +138,6 @@
sendTime := runtime.Str("send-time")

senderEmail := resolveComposeSenderEmail(runtime)
signatureID := runtime.Str("signature-id")
priority, err := parsePriority(runtime.Str("priority"))
if err != nil {
return err
Expand Down Expand Up @@ -195,7 +195,7 @@
}
}

sigResult, err := resolveSignature(ctx, runtime, mailboxID, signatureID, senderEmail)
sigResult, err := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail, sigKindSend)
if err != nil {
return err
}
Expand Down Expand Up @@ -230,7 +230,7 @@
// `lint_applied[]` / `original_blocked[]` even on the plain-text path.
lintApplied, lintBlocked := emptyLintEnvelopeFields()
if plainText {
composedTextBody = body
composedTextBody = appendPlainTextSignature(body, sigResult)

Check warning on line 233 in shortcuts/mail/mail_send.go

View check run for this annotation

Codecov / codecov/patch

shortcuts/mail/mail_send.go#L233

Added line #L233 was not covered by tests
bld = bld.TextBody([]byte(composedTextBody))
} else if bodyIsHTML(body) || sigResult != nil {
// If signature is requested on plain-text body, auto-upgrade to HTML.
Expand Down Expand Up @@ -275,7 +275,7 @@
return err
}
} else {
composedTextBody = body
composedTextBody = appendPlainTextSignature(body, sigResult)
bld = bld.TextBody([]byte(composedTextBody))
}
// Embed template SMALL non-inline attachments via AddAttachment.
Expand Down
Loading
Loading