From fd35044023b3b6cae4eb95c4f4b997873739b153 Mon Sep 17 00:00:00 2001 From: Bence Ferdinandy Date: Thu, 30 May 2024 11:30:18 +0200 Subject: hooks: add AERC_ACCOUNT_BACKEND to hooks with AERC_ACCOUNT It can be good to know the backend used for an account in a hook. Add this information to all hooks that already pass the account name along. Changelog-added: Added `AERC_ACCOUNT_BACKEND` to hooks with `AERC_ACCOUNT`. Signed-off-by: Bence Ferdinandy Acked-by: Robin Jarry --- lib/hooks/flag-changed.go | 2 ++ lib/hooks/mail-added.go | 2 ++ lib/hooks/mail-deleted.go | 2 ++ lib/hooks/mail-received.go | 2 ++ lib/hooks/mail-sent.go | 2 ++ lib/hooks/tag-modified.go | 1 + 6 files changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/hooks/flag-changed.go b/lib/hooks/flag-changed.go index e70b67c0..2e4574c8 100644 --- a/lib/hooks/flag-changed.go +++ b/lib/hooks/flag-changed.go @@ -8,6 +8,7 @@ import ( type FlagChanged struct { Account string + Backend string Folder string Role string FlagName string @@ -20,6 +21,7 @@ func (m *FlagChanged) Cmd() string { func (m *FlagChanged) Env() []string { env := []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), + fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend), fmt.Sprintf("AERC_FOLDER=%s", m.Folder), fmt.Sprintf("AERC_FOLDER_ROLE=%s", m.Role), fmt.Sprintf("AERC_FLAG=%s", m.FlagName), diff --git a/lib/hooks/mail-added.go b/lib/hooks/mail-added.go index 0fa72747..efb3a7dc 100644 --- a/lib/hooks/mail-added.go +++ b/lib/hooks/mail-added.go @@ -8,6 +8,7 @@ import ( type MailAdded struct { Account string + Backend string Folder string Role string } @@ -19,6 +20,7 @@ func (m *MailAdded) Cmd() string { func (m *MailAdded) Env() []string { return []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), + fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend), fmt.Sprintf("AERC_FOLDER=%s", m.Folder), fmt.Sprintf("AERC_FOLDER_ROLE=%s", m.Role), } diff --git a/lib/hooks/mail-deleted.go b/lib/hooks/mail-deleted.go index ca190ee0..ce36e2f9 100644 --- a/lib/hooks/mail-deleted.go +++ b/lib/hooks/mail-deleted.go @@ -8,6 +8,7 @@ import ( type MailDeleted struct { Account string + Backend string Folder string Role string } @@ -19,6 +20,7 @@ func (m *MailDeleted) Cmd() string { func (m *MailDeleted) Env() []string { return []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), + fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend), fmt.Sprintf("AERC_FOLDER=%s", m.Folder), fmt.Sprintf("AERC_FOLDER_ROLE=%s", m.Role), } diff --git a/lib/hooks/mail-received.go b/lib/hooks/mail-received.go index 67457883..fa8247df 100644 --- a/lib/hooks/mail-received.go +++ b/lib/hooks/mail-received.go @@ -9,6 +9,7 @@ import ( type MailReceived struct { Account string + Backend string Folder string Role string MsgInfo *models.MessageInfo @@ -22,6 +23,7 @@ func (m *MailReceived) Env() []string { from := m.MsgInfo.Envelope.From[0] return []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), + fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend), fmt.Sprintf("AERC_FOLDER=%s", m.Folder), fmt.Sprintf("AERC_FROM_NAME=%s", from.Name), fmt.Sprintf("AERC_FROM_ADDRESS=%s", from.Address), diff --git a/lib/hooks/mail-sent.go b/lib/hooks/mail-sent.go index 59edafa2..393670a6 100644 --- a/lib/hooks/mail-sent.go +++ b/lib/hooks/mail-sent.go @@ -9,6 +9,7 @@ import ( type MailSent struct { Account string + Backend string Header *mail.Header } @@ -20,6 +21,7 @@ func (m *MailSent) Env() []string { from, _ := mail.ParseAddress(m.Header.Get("From")) env := []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), + fmt.Sprintf("AERC_ACCOUNT_BACKEND=%s", m.Backend), fmt.Sprintf("AERC_FROM_NAME=%s", from.Name), fmt.Sprintf("AERC_FROM_ADDRESS=%s", from.Address), fmt.Sprintf("AERC_SUBJECT=%s", m.Header.Get("Subject")), diff --git a/lib/hooks/tag-modified.go b/lib/hooks/tag-modified.go index 44af9471..21852803 100644 --- a/lib/hooks/tag-modified.go +++ b/lib/hooks/tag-modified.go @@ -8,6 +8,7 @@ import ( type TagModified struct { Account string + Backend string Add []string Remove []string } -- cgit