diff options
author | Julian Pidancet <julian.pidancet@oracle.com> | 2022-10-26 22:29:02 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-27 21:39:41 +0200 |
commit | f021bfd1c7b7885919cb71884727fd8dfdf8eba7 (patch) | |
tree | 0fe6ce6d038630d0d244b878d2eaf276ee90d0b4 /worker/maildir/message.go | |
parent | 19d16420de3748cdcae2dc9d1a123a1f6fb2425b (diff) | |
download | aerc-f021bfd1c7b7885919cb71884727fd8dfdf8eba7.tar.gz |
maildir: move common maildir code out of worker
This change moves code that could be common to both notmuch and maildir
workers in worker/lib.
Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/maildir/message.go')
-rw-r--r-- | worker/maildir/message.go | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go index 9cd13319..3c8ce9ef 100644 --- a/worker/maildir/message.go +++ b/worker/maildir/message.go @@ -33,7 +33,7 @@ func (m Message) ModelFlags() ([]models.Flag, error) { if err != nil { return nil, err } - return translateMaildirFlags(flags), nil + return lib.FromMaildirFlags(flags), nil } // SetFlags replaces the message's flags with a new set. @@ -91,44 +91,6 @@ func (m Message) NewBodyPartReader(requestedParts []int) (io.Reader, error) { return lib.FetchEntityPartReader(msg, requestedParts) } -var maildirToFlag = map[maildir.Flag]models.Flag{ - maildir.FlagReplied: models.AnsweredFlag, - maildir.FlagSeen: models.SeenFlag, - maildir.FlagTrashed: models.DeletedFlag, - maildir.FlagFlagged: models.FlaggedFlag, - // maildir.FlagDraft Flag = 'D' - // maildir.FlagPassed Flag = 'P' -} - -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 := 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 } |