fix unsolicited fetch response detection

fork
mscdex 12 years ago
parent 23dc0e9c80
commit 44fb676910

@ -272,7 +272,7 @@ The structure of a message with only one part will simply look something like th
Therefore, an easy way to check for a multipart message is to check if the structure length is >1.
Lastly, here are the system flags defined by the IMAP spec (that may be added/removed to/from messages):
Lastly, here are the system flags defined by RFC3501 that may be added/removed:
* Seen - Message has been read
* Answered - Message has been answered

@ -308,11 +308,15 @@ ImapConnection.prototype.connect = function(loginCb) {
// m.info = message details
var data, parsed, headers, f, lenf, body, lenb, msg, bodies,
details, val;
if (!isUnsolicited)
bodies = parsers.parseFetchBodies(m.info, indata.literals);
details = new ImapMessage();
parsers.parseFetch(m.info, indata.literals, details);
details.seqno = parseInt(m.num, 10);
if (isUnsolicited)
self.emit('msgupdate', details);
else {
if (requests[0].fetchers[''] !== undefined) {
// account for non-body fetches
if (bodies) {
@ -339,9 +343,7 @@ ImapConnection.prototype.connect = function(loginCb) {
// we streamed a body, e.g. {3}\r\nfoo
} else {
// no body was streamed
if (isUnsolicited)
self.emit('msgupdate', details);
else if (typeof val === 'string') {
if (typeof val === 'string') {
// a body was given as a non-literal string, e.g. "foo"
if (RE_ISHEADER.test(bodies[body])) {
var parsed, data, headers;
@ -371,6 +373,7 @@ ImapConnection.prototype.connect = function(loginCb) {
}
for (body = 0, lenb = bodies.length; body < lenb; body += 2)
emitMsgEnd(bodies[body]);
}
break;
case 'EXISTS':
// mailbox total message count
@ -1198,7 +1201,6 @@ ImapConnection.prototype._storeLabels = function(which, uids, labels, mode, cb)
if (!Array.isArray(labels))
labels = [labels];
labels = labels.join(' ');
cb = arguments[arguments.length-1];
this._send(which + 'STORE ' + uids.join(',') + ' ' + mode
+ 'X-GM-LABELS.SILENT (' + labels + ')', cb);
@ -1362,7 +1364,6 @@ ImapConnection.prototype._store = function(which, uids, flags, isAdding, cb) {
}
}
flags = flags.join(' ');
cb = arguments[arguments.length-1];
this._send(which + 'STORE ' + uids.join(',') + ' ' + (isAdding ? '+' : '-')
+ 'FLAGS.SILENT (' + flags + ')', cb);

Loading…
Cancel
Save