Get unseen count of mailbox

fork
Chotiwat Chawannakul 12 years ago
parent 507ea8357d
commit e8e2130249

@ -412,7 +412,8 @@ ImapConnection.prototype.connect = function(loginCb) {
uidvalidity: undefined,
messages: {
total: undefined,
new: undefined
new: undefined,
unseen: undefined
}
};
if (m.attributes) {
@ -422,6 +423,9 @@ ImapConnection.prototype.connect = function(loginCb) {
case 'RECENT':
ret.messages.new = parseInt(m.attributes[++i], 10);
break;
case 'UNSEEN':
ret.messages.unseen = parseInt(m.attributes[++i], 10);
break;
case 'MESSAGES':
ret.messages.total = parseInt(m.attributes[++i], 10);
break;
@ -463,7 +467,9 @@ ImapConnection.prototype.connect = function(loginCb) {
} else if (/^ALERT$/i.test(code))
self.emit('alert', m[3]);
else if (state.status === STATES.BOXSELECTING) {
if (m = /^UIDVALIDITY (\d+)/i.exec(code))
if (m = /^UNSEEN (\d+)/i.exec(code))
state.box.unseen = m[1];
else if (m = /^UIDVALIDITY (\d+)/i.exec(code))
state.box.uidvalidity = m[1];
else if (m = /^UIDNEXT (\d+)/i.exec(code))
state.box.uidnext = m[1];
@ -671,7 +677,7 @@ ImapConnection.prototype.status = function(boxName, cb) {
var cmd = 'STATUS "';
cmd += utils.escape(boxName);
cmd += '" (MESSAGES RECENT UIDVALIDITY)';
cmd += '" (MESSAGES RECENT UNSEEN UIDVALIDITY)';
this._send(cmd, cb);
};

Loading…
Cancel
Save