mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 02:42:17 -05:00
Merge pull request #3 from whiteout-io/dev/imap-redesign
dev/imap-redesign
This commit is contained in:
commit
97accd0221
@ -1077,18 +1077,7 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self._imapClient.listMessagesByUid({
|
self._imapClient.getMessage({
|
||||||
path: options.folder,
|
|
||||||
firstUid: options.uid,
|
|
||||||
lastUid: options.uid
|
|
||||||
}, function(err, imapHeaders) {
|
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var imapHeader = imapHeaders[0];
|
|
||||||
self._imapClient.getMessagePreview({
|
|
||||||
path: options.folder,
|
path: options.folder,
|
||||||
uid: options.uid
|
uid: options.uid
|
||||||
}, function(err, message) {
|
}, function(err, message) {
|
||||||
@ -1097,16 +1086,7 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a bastard child of smtp and imap. before thinking this is stupid, talk to the guys who wrote this.
|
callback(null, message);
|
||||||
// p.s. it's a parsing issue.
|
|
||||||
|
|
||||||
imapHeader.id = message.id;
|
|
||||||
imapHeader.body = message.body;
|
|
||||||
imapHeader.html = message.html;
|
|
||||||
imapHeader.attachments = message.attachments;
|
|
||||||
|
|
||||||
callback(null, imapHeader);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -725,24 +725,10 @@ define(function(require) {
|
|||||||
var path = 'FOLDAAAA',
|
var path = 'FOLDAAAA',
|
||||||
uid = 1337;
|
uid = 1337;
|
||||||
|
|
||||||
imapClientStub.listMessagesByUid.withArgs({
|
imapClientStub.getMessage.withArgs({
|
||||||
path: path,
|
|
||||||
firstUid: uid,
|
|
||||||
lastUid: uid
|
|
||||||
}).yields(null, [{
|
|
||||||
uid: uid,
|
|
||||||
subject: 'asdasd',
|
|
||||||
unread: true,
|
|
||||||
answered: false
|
|
||||||
}]);
|
|
||||||
|
|
||||||
imapClientStub.getMessagePreview.withArgs({
|
|
||||||
path: path,
|
path: path,
|
||||||
uid: uid
|
uid: uid
|
||||||
}).yields(null, {
|
}).yields(null, {});
|
||||||
id: 'idididididid',
|
|
||||||
body: 'yes.'
|
|
||||||
});
|
|
||||||
|
|
||||||
dao._imapGetMessage({
|
dao._imapGetMessage({
|
||||||
folder: path,
|
folder: path,
|
||||||
@ -751,17 +737,16 @@ define(function(require) {
|
|||||||
expect(err).to.not.exist;
|
expect(err).to.not.exist;
|
||||||
expect(msg).to.exist;
|
expect(msg).to.exist;
|
||||||
|
|
||||||
expect(imapClientStub.listMessagesByUid.calledOnce).to.be.true;
|
expect(imapClientStub.getMessage.calledOnce).to.be.true;
|
||||||
expect(imapClientStub.getMessagePreview.calledOnce).to.be.true;
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should not work when listMessages fails', function(done) {
|
it('should not work when getMessage fails', function(done) {
|
||||||
var path = 'FOLDAAAA',
|
var path = 'FOLDAAAA',
|
||||||
uid = 1337;
|
uid = 1337;
|
||||||
|
|
||||||
imapClientStub.listMessagesByUid.yields({});
|
imapClientStub.getMessage.yields({});
|
||||||
|
|
||||||
dao._imapGetMessage({
|
dao._imapGetMessage({
|
||||||
folder: path,
|
folder: path,
|
||||||
@ -770,33 +755,7 @@ define(function(require) {
|
|||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
expect(msg).to.not.exist;
|
expect(msg).to.not.exist;
|
||||||
|
|
||||||
expect(imapClientStub.listMessagesByUid.calledOnce).to.be.true;
|
expect(imapClientStub.getMessage.calledOnce).to.be.true;
|
||||||
expect(imapClientStub.getMessagePreview.called).to.be.false;
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should not work when getMessagePreview fails', function(done) {
|
|
||||||
var path = 'FOLDAAAA',
|
|
||||||
uid = 1337;
|
|
||||||
|
|
||||||
imapClientStub.listMessagesByUid.yields(null, [{
|
|
||||||
uid: uid,
|
|
||||||
subject: 'asdasd',
|
|
||||||
unread: true,
|
|
||||||
answered: false
|
|
||||||
}]);
|
|
||||||
imapClientStub.getMessagePreview.yields({});
|
|
||||||
|
|
||||||
dao._imapGetMessage({
|
|
||||||
folder: path,
|
|
||||||
uid: uid
|
|
||||||
}, function(err, msg) {
|
|
||||||
expect(err).to.exist;
|
|
||||||
expect(msg).to.not.exist;
|
|
||||||
|
|
||||||
expect(imapClientStub.listMessagesByUid.calledOnce).to.be.true;
|
|
||||||
expect(imapClientStub.getMessagePreview.calledOnce).to.be.true;
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user