aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/message.go
diff options
context:
space:
mode:
authorGalen Abell <galen@galenabell.com>2020-03-03 08:45:06 -0500
committerReto Brunner <reto@labrat.space>2020-03-03 20:08:37 +0100
commit6ff3c7a1ba680506d77fc1fe8dfbf5b804a3fea7 (patch)
tree093c49f4dc7fbc80adedb5f6c05a76bc697e44b6 /worker/maildir/message.go
parent68f179021d304d6edf939ecf5fc7d0d073b16152 (diff)
downloadaerc-6ff3c7a1ba680506d77fc1fe8dfbf5b804a3fea7.tar.gz
Mark sent messages as "seen" in maildir
- Add maildir flags to complement a messages imap flags - Set the "seen" flag on sent messages when using the maildir backend - Cleanup AppendMessage interface to use models.Flag for both IMAP and maildir
Diffstat (limited to 'worker/maildir/message.go')
-rw-r--r--worker/maildir/message.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go
index 45b1ca62..9d622b45 100644
--- a/worker/maildir/message.go
+++ b/worker/maildir/message.go
@@ -45,7 +45,7 @@ func (m Message) ModelFlags() ([]models.Flag, error) {
if err != nil {
return nil, err
}
- return translateFlags(flags), nil
+ return translateMaildirFlags(flags), nil
}
// SetFlags replaces the message's flags with a new set.
@@ -97,7 +97,7 @@ func (m Message) NewBodyPartReader(requestedParts []int) (io.Reader, error) {
return lib.FetchEntityPartReader(msg, requestedParts)
}
-var flagMap = map[maildir.Flag]models.Flag{
+var maildirToFlag = map[maildir.Flag]models.Flag{
maildir.FlagReplied: models.AnsweredFlag,
maildir.FlagSeen: models.SeenFlag,
maildir.FlagTrashed: models.DeletedFlag,
@@ -106,16 +106,35 @@ var flagMap = map[maildir.Flag]models.Flag{
// maildir.FlagPassed Flag = 'P'
}
-func translateFlags(maildirFlags []maildir.Flag) []models.Flag {
+var flagToMaildir = map[models.Flag]maildir.Flag{
+ models.AnsweredFlag: maildir.FlagReplied,
+ models.SeenFlag: maildir.FlagSeen,
+ models.DeletedFlag: maildir.FlagTrashed,
+ models.FlaggedFlag: maildir.FlagFlagged,
+ // maildir.FlagDraft Flag = 'D'
+ // maildir.FlagPassed Flag = 'P'
+}
+
+func translateMaildirFlags(maildirFlags []maildir.Flag) []models.Flag {
var flags []models.Flag
for _, maildirFlag := range maildirFlags {
- if flag, ok := flagMap[maildirFlag]; ok {
+ if flag, ok := maildirToFlag[maildirFlag]; ok {
flags = append(flags, flag)
}
}
return flags
}
+func translateFlags(flags []models.Flag) []maildir.Flag {
+ var maildirFlags []maildir.Flag
+ for _, flag := range flags {
+ if maildirFlag, ok := flagToMaildir[flag]; ok {
+ maildirFlags = append(maildirFlags, maildirFlag)
+ }
+ }
+ return maildirFlags
+}
+
func (m Message) UID() uint32 {
return m.uid
}