aboutsummaryrefslogtreecommitdiffstats
path: root/commands/compose/send.go
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2023-05-10 17:47:07 -0400
committerRobin Jarry <robin@jarry.cc>2023-05-16 13:56:52 +0200
commit0eaf05d3fa6295e7df06793a967d3389d2a0f7d8 (patch)
tree86d1c82fc1b81b194db3d77ac0025187328c7c5e /commands/compose/send.go
parentd2ea1aac09fbf02873c3070cadef4386196bb040 (diff)
downloadaerc-0eaf05d3fa6295e7df06793a967d3389d2a0f7d8.tar.gz
compose: warn before sending with empty subject
Ask user whether they want to abort before sending if the subject header is empty and they have enabled the warn-empty-subject config option. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'commands/compose/send.go')
-rw-r--r--commands/compose/send.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index d43f28ea..eeea96cd 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -109,12 +109,17 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
log.Debugf("send config rcpts: %s", ctx.rcpts)
log.Debugf("send config domain: %s", ctx.domain)
- warn, err := composer.ShouldWarnAttachment()
- if err != nil || warn {
- msg := "You may have forgotten an attachment."
- if err != nil {
- log.Warnf("failed to check for a forgotten attachment: %v", err)
- msg = "Failed to check for a forgotten attachment."
+ warnSubject := composer.ShouldWarnSubject()
+ warnAttachment := composer.ShouldWarnAttachment()
+ if warnSubject || warnAttachment {
+ var msg string
+ switch {
+ case warnSubject && warnAttachment:
+ msg = "The subject is empty, and you may have forgotten an attachment."
+ case warnSubject:
+ msg = "The subject is empty."
+ default:
+ msg = "You may have forgotten an attachment."
}
prompt := widgets.NewPrompt(