From faa879f9a84d44f9b251410fc923a827a44df1a7 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sun, 29 Oct 2023 17:40:48 -0400 Subject: hooks: add mail-added hook The mail-added hook runs whenever a message is added to a folder. Note that the hook does not run when a new message is received (the mail-received hook already covers that) but instead runs whenever aerc itself adds a message to a folder, e.g. when moving or copying a message. Changelog-added: `mail-added` hook that triggers when a message is added to a folder. References: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Jason Cox Acked-by: Robin Jarry --- app/account.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/account.go') diff --git a/app/account.go b/app/account.go index b5bed86e..734ba37a 100644 --- a/app/account.go +++ b/app/account.go @@ -265,6 +265,15 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore { msg := fmt.Sprintf("mail-deleted hook: %s", err) PushError(msg) } + }, func(dest string) { + err := hooks.RunHook(&hooks.MailAdded{ + Account: acct.Name(), + Folder: dest, + }) + if err != nil { + msg := fmt.Sprintf("mail-added hook: %s", err) + PushError(msg) + } }, acct.updateSplitView, acct.dirlist.UiConfig(name).ThreadContext, -- cgit