aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/message.go
diff options
context:
space:
mode:
authorSrivathsan Murali <sri@vathsan.com>2020-05-25 16:59:48 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-25 11:29:53 -0400
commitb1eb7ad18d2e0bbeecaf61a58825bbc794ceb40c (patch)
tree310ff7fa90dfb23c303b7f89674b8411bd8cdf89 /worker/maildir/message.go
parenta31d184ba53a9a61b8a0eed42cee52f9b1f2dc51 (diff)
downloadaerc-b1eb7ad18d2e0bbeecaf61a58825bbc794ceb40c.tar.gz
Set AnsweredFlag on successful reply
Diffstat (limited to 'worker/maildir/message.go')
-rw-r--r--worker/maildir/message.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go
index 9d622b45..5c6c9307 100644
--- a/worker/maildir/message.go
+++ b/worker/maildir/message.go
@@ -53,6 +53,26 @@ func (m Message) SetFlags(flags []maildir.Flag) error {
return m.dir.SetFlags(m.key, flags)
}
+// MarkReplied either adds or removes the maildir.FlagReplied flag from the
+// message.
+func (m Message) MarkReplied(answered bool) error {
+ flags, err := m.Flags()
+ if err != nil {
+ return fmt.Errorf("could not read previous flags: %v", err)
+ }
+ if answered {
+ flags = append(flags, maildir.FlagReplied)
+ return m.SetFlags(flags)
+ }
+ var newFlags []maildir.Flag
+ for _, flag := range flags {
+ if flag != maildir.FlagReplied {
+ newFlags = append(newFlags, flag)
+ }
+ }
+ return m.SetFlags(newFlags)
+}
+
// MarkRead either adds or removes the maildir.FlagSeen flag from the message.
func (m Message) MarkRead(seen bool) error {
flags, err := m.Flags()