aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch
diff options
context:
space:
mode:
Diffstat (limited to 'worker/notmuch')
-rw-r--r--worker/notmuch/message.go20
-rw-r--r--worker/notmuch/worker.go5
2 files changed, 10 insertions, 15 deletions
diff --git a/worker/notmuch/message.go b/worker/notmuch/message.go
index 0fc85b00..28731d3d 100644
--- a/worker/notmuch/message.go
+++ b/worker/notmuch/message.go
@@ -58,7 +58,7 @@ func (m *Message) NewBodyPartReader(requestedParts []int) (io.Reader, error) {
// SetFlag adds or removes a flag from the message.
// Notmuch doesn't support all the flags, and for those this errors.
-func (m *Message) SetFlag(flag models.Flag, enable bool) error {
+func (m *Message) SetFlag(flag models.Flags, enable bool) error {
// Translate the flag into a notmuch tag, ignoring no-op flags.
var tag string
switch flag {
@@ -129,28 +129,22 @@ func (m *Message) Labels() ([]string, error) {
return m.Tags()
}
-func (m *Message) ModelFlags() ([]models.Flag, error) {
- var flags []models.Flag
- seen := true
+func (m *Message) ModelFlags() (models.Flags, error) {
+ var flags models.Flags = models.SeenFlag
tags, err := m.Tags()
if err != nil {
- return nil, err
+ return 0, err
}
for _, tag := range tags {
switch tag {
case "replied":
- flags = append(flags, models.AnsweredFlag)
+ flags |= models.AnsweredFlag
case "flagged":
- flags = append(flags, models.FlaggedFlag)
+ flags |= models.FlaggedFlag
case "unread":
- seen = false
- default:
- continue
+ flags &^= models.SeenFlag
}
}
- if seen {
- flags = append(flags, models.SeenFlag)
- }
return flags, nil
}
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index a4f5b5c8..6d8e46d2 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -477,8 +477,9 @@ func (w *worker) handleFlagMessages(msg *types.FlagMessages) error {
w.err(msg, err)
continue
}
- if err := m.SetFlag(msg.Flag, msg.Enable); err != nil {
- log.Errorf("could not set flag %v as %t for message: %v", msg.Flag, msg.Enable, err)
+ if err := m.SetFlag(msg.Flags, msg.Enable); err != nil {
+ log.Errorf("could not set flag %v as %t for message: %v",
+ msg.Flags, msg.Enable, err)
w.err(msg, err)
continue
}