aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/imap.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/imap/imap.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/imap/imap.go')
-rw-r--r--worker/imap/imap.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/worker/imap/imap.go b/worker/imap/imap.go
index b0aacf62..fdcbc380 100644
--- a/worker/imap/imap.go
+++ b/worker/imap/imap.go
@@ -89,7 +89,7 @@ func translateAddresses(addrs []*imap.Address) []*models.Address {
return converted
}
-var flagMap = map[string]models.Flag{
+var imapToFlag = map[string]models.Flag{
imap.SeenFlag: models.SeenFlag,
imap.RecentFlag: models.RecentFlag,
imap.AnsweredFlag: models.AnsweredFlag,
@@ -97,12 +97,30 @@ var flagMap = map[string]models.Flag{
imap.FlaggedFlag: models.FlaggedFlag,
}
-func translateFlags(imapFlags []string) []models.Flag {
+var flagToImap = map[models.Flag]string{
+ models.SeenFlag: imap.SeenFlag,
+ models.RecentFlag: imap.RecentFlag,
+ models.AnsweredFlag: imap.AnsweredFlag,
+ models.DeletedFlag: imap.DeletedFlag,
+ models.FlaggedFlag: imap.FlaggedFlag,
+}
+
+func translateImapFlags(imapFlags []string) []models.Flag {
var flags []models.Flag
for _, imapFlag := range imapFlags {
- if flag, ok := flagMap[imapFlag]; ok {
+ if flag, ok := imapToFlag[imapFlag]; ok {
flags = append(flags, flag)
}
}
return flags
}
+
+func translateFlags(flags []models.Flag) []string {
+ var imapFlags []string
+ for _, flag := range flags {
+ if imapFlag, ok := flagToImap[flag]; ok {
+ imapFlags = append(imapFlags, imapFlag)
+ }
+ }
+ return imapFlags
+}