aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account/fetch-msg.go
blob: 631a8eede22a557c8044f3631380254a7f7afbad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package account

import (
	"errors"

	"github.com/mohamedattahri/mail"

	"git.sr.ht/~sircmpwn/aerc2/widgets"
)

func init() {
	register("fetch-message", FetchMessage)
}

func FetchMessage(aerc *widgets.Aerc, args []string) error {
	if len(args) != 1 {
		return errors.New("Usage: :fetch-message")
	}
	acct := aerc.SelectedAccount()
	if acct == nil {
		return errors.New("No account selected")
	}
	store := acct.Messages().Store()
	msg := acct.Messages().Selected()
	store.FetchBodies([]uint32{msg.Uid}, func(msg *mail.Message) {
		aerc.SetStatus("got message body, woohoo")
	})
	return nil
}