1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-22 07:18:49 -05:00

[WO-855] Fix trying to set a flag when email is deleted

This commit is contained in:
Felix Hammerl 2015-02-12 16:18:42 +01:00 committed by Tankred Hase
parent 3da5a55251
commit 2e3e07aa1d
2 changed files with 32 additions and 0 deletions

View File

@ -492,6 +492,12 @@ Email.prototype.setFlags = function(options) {
}).then(function(storedMessages) {
// set the flags
var storedMessage = storedMessages[0];
if (!storedMessage) {
// the message has been deleted in the meantime
return;
}
storedMessage.unread = options.message.unread;
storedMessage.flagged = options.message.flagged;
storedMessage.answered = options.message.answered;

View File

@ -733,6 +733,32 @@ describe('Email DAO unit tests', function() {
});
});
it('should not explode when message has been deleted during imap roundtrip', function(done) {
imapMark.withArgs({
folder: inboxFolder,
uid: message.uid,
unread: message.unread,
answered: message.answered,
flagged: message.flagged
}).returns(resolves());
localListStub.withArgs({
folder: inboxFolder,
uid: message.uid
}).returns(resolves([]));
dao.setFlags({
folder: inboxFolder,
message: message
}).then(function() {
expect(imapMark.calledOnce).to.be.true;
expect(localListStub.calledOnce).to.be.true;
expect(localStoreStub.called).to.be.false;
done();
});
});
it('should set flags for outbox for disk, memory', function(done) {
localListStub.withArgs({
folder: outboxFolder,