aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/checkmail.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2023-04-16 09:53:37 -0500
committerRobin Jarry <robin@jarry.cc>2023-04-22 22:40:12 +0200
commit82de08a8a3f55c438d8808e3c759e3d99261c4b8 (patch)
treeea658d1524029a3a8e32b1c64570dc5d1281f6e0 /worker/imap/checkmail.go
parent91ac21ac615582e2dd5e36f4b36bde1bc0bf38d8 (diff)
downloadaerc-82de08a8a3f55c438d8808e3c759e3d99261c4b8.tar.gz
imap: properly handle mailbox status updates
Mailbox status updates received from the IMAP server do not come with the information being sent to the UI. Use the update signal to instead trigger a check-mail of the directory the status was sent for. The status update comes with the following data: - Messages in the mailbox - Recent messages in the mailbox - Sequence number of the first Unseen message - Flags in the mailbox The data we actually we want to send to the UI: - Messages in the mailbox - Recent messages in the mailbox - Unseen messages in the mailbox Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/imap/checkmail.go')
-rw-r--r--worker/imap/checkmail.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/worker/imap/checkmail.go b/worker/imap/checkmail.go
index c1b6ec4c..9c1f14c1 100644
--- a/worker/imap/checkmail.go
+++ b/worker/imap/checkmail.go
@@ -12,6 +12,7 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) {
imap.StatusMessages,
imap.StatusRecent,
imap.StatusUnseen,
+ imap.StatusUidNext,
}
var (
statuses []*imap.MailboxStatus
@@ -48,6 +49,13 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) {
}
}
for _, status := range statuses {
+ refetch := false
+ if status.Name == w.selected.Name {
+ if status.UidNext != w.selected.UidNext {
+ refetch = true
+ }
+ w.selected = status
+ }
w.worker.PostMessage(&types.DirectoryInfo{
Info: &models.DirectoryInfo{
Flags: status.Flags,
@@ -60,6 +68,7 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) {
Unseen: int(status.Unseen),
Caps: w.caps,
},
+ Refetch: refetch,
}, nil)
}
if len(remaining) > 0 {