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 --- commands/compose/postpone.go | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'commands/compose/postpone.go') diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go index 3ce9cc84..098b7039 100644 --- a/commands/compose/postpone.go +++ b/commands/compose/postpone.go @@ -34,6 +34,10 @@ func (p Postpone) Execute(args []string) error { if acct == nil { return errors.New("No account selected") } + store := acct.Store() + if store == nil { + return errors.New("No message store selected") + } tab := app.SelectedTab() if tab == nil { return errors.New("No tab selected") @@ -98,22 +102,23 @@ func (p Postpone) Execute(args []string) error { handleErr(errors.Wrap(err, "WriteMessage")) return } - worker.PostAction(&types.AppendMessage{ - Destination: targetFolder, - Flags: models.SeenFlag, - Date: time.Now(), - Reader: buf, - Length: buf.Len(), - }, func(msg types.WorkerMessage) { - switch msg := msg.(type) { - case *types.Done: - app.PushStatus("Message postponed.", 10*time.Second) - composer.SetPostponed() - composer.Close() - case *types.Error: - handleErr(msg.Error) - } - }) + store.Append( + targetFolder, + models.SeenFlag, + time.Now(), + buf, + buf.Len(), + func(msg types.WorkerMessage) { + switch msg := msg.(type) { + case *types.Done: + app.PushStatus("Message postponed.", 10*time.Second) + composer.SetPostponed() + composer.Close() + case *types.Error: + handleErr(msg.Error) + } + }, + ) }() if !alreadyCreated { -- cgit