aboutsummaryrefslogtreecommitdiffstats
path: root/commands/compose/send.go
diff options
context:
space:
mode:
authorMoritz Poldrack <git@moritz.sh>2024-01-22 18:28:17 +0100
committerRobin Jarry <robin@jarry.cc>2024-01-25 21:55:23 +0100
commit0e592b28802fe7d972dac2b4958284b9eaf274a0 (patch)
tree8830a87ea58cdd7b65e07548e71e06195de4ae05 /commands/compose/send.go
parent1980744f7bf9e147abf649d37a2fa7dddd4e7254 (diff)
downloadaerc-0e592b28802fe7d972dac2b4958284b9eaf274a0.tar.gz
hook: add mail-sent hook
Add a hook to trigger when a message is sent. References: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Moritz Poldrack <git@moritz.sh> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/compose/send.go')
-rw-r--r--commands/compose/send.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index dfd531ee..13d9fd4a 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -19,6 +19,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands/mode"
"git.sr.ht/~rjarry/aerc/commands/msg"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/lib/hooks"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -247,6 +248,14 @@ func send(composer *app.Composer, ctx sendCtx,
}
app.PushStatus("Message sent.", 10*time.Second)
composer.SetSent(ctx.archive)
+ err = hooks.RunHook(&hooks.MailSent{
+ Account: composer.Account().Name(),
+ Header: header,
+ })
+ if err != nil {
+ log.Errorf("failed to trigger mail-sent hook: %v", err)
+ composer.Account().PushError(fmt.Errorf("[hook.mail-sent] failed: %w", err))
+ }
composer.Close()
}()
}