Debian Codegraph @

lib/hooks/mail-received.go

raw
1 package hooks
2
3 import (
4 "fmt"
5
6 "git.sr.ht/~rjarry/aerc/config"
7 "git.sr.ht/~rjarry/aerc/models"
8 )
9
10 type MailReceived struct {
11 Account string
12 Backend string
13 Folder string
14 Role string
15 MsgInfo *models.MessageInfo
16 }
17
18 func (m *MailReceived) Cmd() string {
19 return config.Hooks().MailReceived
20 }
21
22 func (m *MailReceived) Env() []string {
23 from := m.MsgInfo.Envelope.From[0]
24 return []string{
25 fmt.Sprintf("AERC_ACCOUNT=%s", m.Account),
26 fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend),
27 fmt.Sprintf("AERC_FOLDER=%s", m.Folder),
28 fmt.Sprintf("AERC_FROM_NAME=%s", from.Name),
29 fmt.Sprintf("AERC_FROM_ADDRESS=%s", from.Address),
30 fmt.Sprintf("AERC_SUBJECT=%s", m.MsgInfo.Envelope.Subject),
31 fmt.Sprintf("AERC_MESSAGE_ID=%s", m.MsgInfo.Envelope.MessageId),
32 fmt.Sprintf("AERC_FOLDER_ROLE=%s", m.Role),
33 }
34 }