Skip to content

Commit c8f438d

Browse files
committed
imapserver: add SessionTracker.EncodeNumMessages
1 parent c1c8ede commit c8f438d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

imapserver/tracker.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,20 @@ func (t *SessionTracker) EncodeSeqNum(seqNum uint32) uint32 {
282282
}
283283
return seqNum
284284
}
285+
286+
// EncodeNumMessages returns the number of messages in the mailbox from the
287+
// client point-of-view.
288+
func (t *SessionTracker) EncodeNumMessages() uint32 {
289+
n := t.mailbox.numMessages
290+
for i := len(t.queue) - 1; i >= 0; i-- {
291+
update := t.queue[i]
292+
// TODO: this doesn't handle increments > 1
293+
if update.numMessages != 0 {
294+
n--
295+
}
296+
if update.expunge != 0 {
297+
n++
298+
}
299+
}
300+
return n
301+
}

0 commit comments

Comments
 (0)