diff options
author | Bence Ferdinandy <bence@ferdinandy.com> | 2024-05-30 11:30:16 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-06-05 08:41:13 +0200 |
commit | 74bba6745d2bf1120d143a9898c8a7204d9d20e9 (patch) | |
tree | 22a90d0c1d5620ad56ddd8a87db3413e3793077b | |
parent | 77d08620b5b2a69ee300eca66165a5c6492919d0 (diff) | |
download | aerc-74bba6745d2bf1120d143a9898c8a7204d9d20e9.tar.gz |
hooks: add AERC_FOLDER_ROLE to hooks with AERC_FOLDER
It's logical to pass this information as well, when we pass a folder
name.
Changelog-added: Added `AERC_FOLDER_ROLE` to hooks that have
`AERC_FOLDER`.
Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | app/account.go | 9 | ||||
-rw-r--r-- | doc/aerc-config.5.scd | 4 | ||||
-rw-r--r-- | lib/hooks/flag-changed.go | 2 | ||||
-rw-r--r-- | lib/hooks/mail-added.go | 2 | ||||
-rw-r--r-- | lib/hooks/mail-deleted.go | 2 | ||||
-rw-r--r-- | lib/hooks/mail-received.go | 2 |
6 files changed, 21 insertions, 0 deletions
diff --git a/app/account.go b/app/account.go index 07c6801d..20e64e74 100644 --- a/app/account.go +++ b/app/account.go @@ -242,6 +242,11 @@ func (acct *AccountView) isSelected() bool { func (acct *AccountView) newStore(name string) *lib.MessageStore { uiConf := acct.dirlist.UiConfig(name) + dir := acct.dirlist.Directory(name) + role := "" + if dir != nil { + role = string(dir.Role) + } store := lib.NewMessageStore(acct.worker, acct.sortCriteria(uiConf), uiConf.ThreadingEnabled, @@ -255,6 +260,7 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore { err := hooks.RunHook(&hooks.MailReceived{ Account: acct.Name(), Folder: name, + Role: role, MsgInfo: msg, }) if err != nil { @@ -269,6 +275,7 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore { err := hooks.RunHook(&hooks.MailDeleted{ Account: acct.Name(), Folder: name, + Role: role, }) if err != nil { msg := fmt.Sprintf("mail-deleted hook: %s", err) @@ -278,6 +285,7 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore { err := hooks.RunHook(&hooks.MailAdded{ Account: acct.Name(), Folder: dest, + Role: role, }) if err != nil { msg := fmt.Sprintf("mail-added hook: %s", err) @@ -297,6 +305,7 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore { err := hooks.RunHook(&hooks.FlagChanged{ Account: acct.Name(), Folder: acct.SelectedDirectory(), + Role: role, FlagName: flagname, }) if err != nil { diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 17cea5ff..b7a1f120 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -1198,6 +1198,7 @@ They are configured in the *[hooks]* section of aerc.conf. - *AERC_ACCOUNT* - *AERC_FOLDER* + - *AERC_FOLDER_ROLE* - *AERC_FROM_NAME* - *AERC_FROM_ADDRESS* - *AERC_SUBJECT* @@ -1215,6 +1216,7 @@ They are configured in the *[hooks]* section of aerc.conf. - *AERC_ACCOUNT* - *AERC_FOLDER* + - *AERC_FOLDER_ROLE* Example: @@ -1230,6 +1232,7 @@ They are configured in the *[hooks]* section of aerc.conf. - *AERC_ACCOUNT* - *AERC_FOLDER* + - *AERC_FOLDER_ROLE* Example: @@ -1278,6 +1281,7 @@ They are configured in the *[hooks]* section of aerc.conf. - *AERC_ACCOUNT* - *AERC_FOLDER* + - *AERC_FOLDER_ROLE* - *AERC_FLAG* Example: diff --git a/lib/hooks/flag-changed.go b/lib/hooks/flag-changed.go index aaeff014..e70b67c0 100644 --- a/lib/hooks/flag-changed.go +++ b/lib/hooks/flag-changed.go @@ -9,6 +9,7 @@ import ( type FlagChanged struct { Account string Folder string + Role string FlagName string } @@ -20,6 +21,7 @@ func (m *FlagChanged) Env() []string { env := []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), 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 f146d010..0fa72747 100644 --- a/lib/hooks/mail-added.go +++ b/lib/hooks/mail-added.go @@ -9,6 +9,7 @@ import ( type MailAdded struct { Account string Folder string + Role string } func (m *MailAdded) Cmd() string { @@ -19,5 +20,6 @@ func (m *MailAdded) Env() []string { return []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), 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 e9f13105..ca190ee0 100644 --- a/lib/hooks/mail-deleted.go +++ b/lib/hooks/mail-deleted.go @@ -9,6 +9,7 @@ import ( type MailDeleted struct { Account string Folder string + Role string } func (m *MailDeleted) Cmd() string { @@ -19,5 +20,6 @@ func (m *MailDeleted) Env() []string { return []string{ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account), 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 99d3ceef..67457883 100644 --- a/lib/hooks/mail-received.go +++ b/lib/hooks/mail-received.go @@ -10,6 +10,7 @@ import ( type MailReceived struct { Account string Folder string + Role string MsgInfo *models.MessageInfo } @@ -26,5 +27,6 @@ func (m *MailReceived) Env() []string { fmt.Sprintf("AERC_FROM_ADDRESS=%s", from.Address), fmt.Sprintf("AERC_SUBJECT=%s", m.MsgInfo.Envelope.Subject), fmt.Sprintf("AERC_MESSAGE_ID=%s", m.MsgInfo.Envelope.MessageId), + fmt.Sprintf("AERC_FOLDER_ROLE=%s", m.Role), } } |