aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2024-04-10 20:08:00 +0200
committerRobin Jarry <robin@jarry.cc>2024-04-14 11:50:39 +0200
commitcee5d5a3f602e5db0ca3feb6e0754c1bb0059f36 (patch)
treec380b0cb317a62d17b6ff4922fbc6c95486f3295 /lib
parentae3f7419ce1b6d4a81c4f240ff1073ba45f45b52 (diff)
downloadaerc-cee5d5a3f602e5db0ca3feb6e0754c1bb0059f36.tar.gz
hooks: add tag-modified
Add the tag-modified hook for notmuch and JMAP accounts. References: https://todo.sr.ht/~rjarry/aerc/136 Changelog-added: New `tag-modified` hook for notmuch and JMAP accounts. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/hooks/tag-modified.go27
-rw-r--r--lib/msgstore.go12
2 files changed, 37 insertions, 2 deletions
diff --git a/lib/hooks/tag-modified.go b/lib/hooks/tag-modified.go
new file mode 100644
index 00000000..44af9471
--- /dev/null
+++ b/lib/hooks/tag-modified.go
@@ -0,0 +1,27 @@
+package hooks
+
+import (
+ "fmt"
+
+ "git.sr.ht/~rjarry/aerc/config"
+)
+
+type TagModified struct {
+ Account string
+ Add []string
+ Remove []string
+}
+
+func (m *TagModified) Cmd() string {
+ return config.Hooks.TagModified
+}
+
+func (m *TagModified) Env() []string {
+ env := []string{
+ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account),
+ fmt.Sprintf("AERC_TAG_ADDED=%v", m.Add),
+ fmt.Sprintf("AERC_TAG_REMOVED=%v", m.Remove),
+ }
+
+ return env
+}
diff --git a/lib/msgstore.go b/lib/msgstore.go
index d11d280e..a906d0cc 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -70,6 +70,7 @@ type MessageStore struct {
triggerDirectoryChange func()
triggerMailDeleted func()
triggerMailAdded func(string)
+ triggerTagModified func([]string, []string)
threadBuilderDebounce *time.Timer
threadBuilderDelay time.Duration
@@ -90,7 +91,8 @@ func NewMessageStore(worker *types.Worker,
reverseOrder bool, reverseThreadOrder bool, sortThreadSiblings bool,
triggerNewEmail func(*models.MessageInfo),
triggerDirectoryChange func(), triggerMailDeleted func(),
- triggerMailAdded func(string), onSelect func(*models.MessageInfo),
+ triggerMailAdded func(string), triggerTagModified func([]string, []string),
+ onSelect func(*models.MessageInfo),
threadContext bool,
) *MessageStore {
if !worker.Backend.Capabilities().Thread {
@@ -129,6 +131,7 @@ func NewMessageStore(worker *types.Worker,
triggerDirectoryChange: triggerDirectoryChange,
triggerMailDeleted: triggerMailDeleted,
triggerMailAdded: triggerMailAdded,
+ triggerTagModified: triggerTagModified,
threadBuilderDelay: clientThreadsDelay,
@@ -885,7 +888,12 @@ func (store *MessageStore) ModifyLabels(uids []uint32, add, remove []string,
Uids: uids,
Add: add,
Remove: remove,
- }, cb)
+ }, func(msg types.WorkerMessage) {
+ if _, ok := msg.(*types.Done); ok {
+ store.triggerTagModified(add, remove)
+ }
+ cb(msg)
+ })
}
func (store *MessageStore) Sort(criteria []*types.SortCriterion, cb func(types.WorkerMessage)) {