diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/compose.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index 1e7450e9..4735782b 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -853,24 +853,36 @@ func (c *Composer) WriteMessage(header *mail.Header, writer io.Writer) error { } } -func (c *Composer) ShouldWarnAttachment() (bool, error) { +func (c *Composer) ShouldWarnAttachment() bool { regex := config.Compose.NoAttachmentWarning if regex == nil || len(c.attachments) > 0 { - return false, nil + return false } err := c.reloadEmail() if err != nil { - return false, errors.Wrap(err, "reloadEmail") + log.Warnf("failed to check for a forgotten attachment (reloadEmail): %v", err) + return true } body, err := io.ReadAll(c.email) if err != nil { - return false, errors.Wrap(err, "io.ReadAll") + log.Warnf("failed to check for a forgotten attachment (io.ReadAll): %v", err) + return true + } + + return regex.Match(body) +} + +func (c *Composer) ShouldWarnSubject() bool { + if !config.Compose.EmptySubjectWarning { + return false } - return regex.Match(body), nil + // ignore errors because the raw header field is sufficient here + subject, _ := c.header.Subject() + return len(subject) == 0 } func writeMsgImpl(c *Composer, header *mail.Header, writer io.Writer) error { |