aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--worker/imap/checkmail.go9
-rw-r--r--worker/imap/worker.go17
2 files changed, 11 insertions, 15 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 {
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 752eac52..8673c0ff 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -249,21 +249,8 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
log.Tracef("(= %T", update)
switch update := update.(type) {
case *client.MailboxUpdate:
- status := update.Mailbox
- if w.selected.Name == status.Name {
- w.selected = status
- }
- w.worker.PostMessage(&types.DirectoryInfo{
- Info: &models.DirectoryInfo{
- Flags: status.Flags,
- Name: status.Name,
- ReadOnly: status.ReadOnly,
-
- Exists: int(status.Messages),
- Recent: int(status.Recent),
- Unseen: int(status.Unseen),
- Caps: w.caps,
- },
+ w.worker.PostAction(&types.CheckMail{
+ Directories: []string{update.Mailbox.Name},
}, nil)
case *client.MessageUpdate:
msg := update.Message