aboutsummaryrefslogtreecommitdiff
path: root/worker/imap/fetch.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-06-09 14:55:04 -0400
committerDrew DeVault <sir@cmpwn.com>2019-06-09 14:55:04 -0400
commit05f00f0153066b9bb527773927a3244dad28ef4f (patch)
tree1e3dbd574e358fbeaf4cf46774baf1a329f649ab /worker/imap/fetch.go
parentd63653ecdeb19c0fb4b3ea976c3e5ea96b408112 (diff)
Update our message flags when server updates them
Diffstat (limited to 'worker/imap/fetch.go')
-rw-r--r--worker/imap/fetch.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index 2d5bb7f..7d1bfcf 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -40,7 +40,11 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart(
imapw.worker.Logger.Printf("Fetching message part")
section := &imap.BodySectionName{}
section.Path = msg.Part
- items := []imap.FetchItem{section.FetchItem()}
+ items := []imap.FetchItem{
+ imap.FetchFlags,
+ imap.FetchUid,
+ section.FetchItem(),
+ }
uids := imap.SeqSet{}
uids.AddNum(msg.Uid)
imapw.handleFetchMessages(msg, &uids, items, section)
@@ -51,7 +55,11 @@ func (imapw *IMAPWorker) handleFetchFullMessages(
imapw.worker.Logger.Printf("Fetching full messages")
section := &imap.BodySectionName{}
- items := []imap.FetchItem{section.FetchItem()}
+ items := []imap.FetchItem{
+ imap.FetchFlags,
+ imap.FetchUid,
+ section.FetchItem(),
+ }
imapw.handleFetchMessages(msg, &msg.Uids, items, section)
}
@@ -89,6 +97,12 @@ func (imapw *IMAPWorker) handleFetchMessages(
Reader: reader,
Uid: _msg.Uid,
}, nil)
+ // Update flags (to mark message as read)
+ imapw.worker.PostMessage(&types.MessageInfo{
+ Message: types.RespondTo(msg),
+ Flags: _msg.Flags,
+ Uid: _msg.Uid,
+ }, nil)
case *types.FetchMessageBodyPart:
reader := _msg.GetBody(section)
imapw.worker.PostMessage(&types.MessageBodyPart{
@@ -96,6 +110,12 @@ func (imapw *IMAPWorker) handleFetchMessages(
Reader: reader,
Uid: _msg.Uid,
}, nil)
+ // Update flags (to mark message as read)
+ imapw.worker.PostMessage(&types.MessageInfo{
+ Message: types.RespondTo(msg),
+ Flags: _msg.Flags,
+ Uid: _msg.Uid,
+ }, nil)
}
}
done <- nil