1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 01:12:19 -05:00

Merge pull request #58 from whiteout-io/dev/WO-284

[WO-284] delete mails to trash folder
This commit is contained in:
Tankred Hase 2014-05-12 17:37:16 +02:00
commit 6c329b3772
2 changed files with 42 additions and 8 deletions

View File

@ -743,8 +743,26 @@ define(function(require) {
return;
}
options.path = options.folder;
this._imapClient.deleteMessage(options, callback);
var trash = _.findWhere(this._account.folders, {
type: 'Trash'
});
// there's no known trash folder to move the mail to or we're in the trash folder,
// so we can purge the message
if (!trash || options.folder === trash.path) {
this._imapClient.deleteMessage({
path: options.folder,
uid: options.uid
}, callback);
return;
}
this._imapClient.moveMessage({
path: options.folder,
destination: trash.path,
uid: options.uid
}, callback);
};
/**

View File

@ -13,7 +13,7 @@ define(function(require) {
describe('Email Sync unit tests', function() {
var emailSync, keychainStub, imapClientStub, devicestorageStub;
var emailAddress, mockkeyId, dummyEncryptedMail,
var emailAddress, mockkeyId, dummyEncryptedMail, trashMailbox,
dummyDecryptedMail, mockKeyPair, account, verificationMail, verificationUuid, corruptedVerificationUuid,
nonWhitelistedMail;
@ -106,6 +106,10 @@ define(function(require) {
expect(emailSync._keychain).to.equal(keychainStub);
expect(emailSync._devicestorage).to.equal(devicestorageStub);
expect(emailSync._mailreader).to.equal(mailreader);
trashMailbox = {
type: 'Trash',
path: 'trash'
};
// init
emailSync.init({
@ -118,7 +122,7 @@ define(function(require) {
expect(emailSync._imapClient).to.not.exist;
expect(emailSync._smtpClient).to.not.exist;
expect(emailSync._account.online).to.be.undefined;
emailSync._account.folders = [];
emailSync._account.folders = [trashMailbox];
imapClientStub.login.yields();
// this is set in the emailDao.onConnect
@ -214,11 +218,11 @@ define(function(require) {
});
});
it('should work', function(done) {
imapClientStub.deleteMessage.withArgs({
it('should move to trash', function(done) {
imapClientStub.moveMessage.withArgs({
path: path,
folder: path,
uid: uid
uid: uid,
destination: trashMailbox.path
}).yields();
emailSync._imapDeleteMessage({
@ -226,6 +230,18 @@ define(function(require) {
uid: uid
}, done);
});
it('should purge message', function(done) {
imapClientStub.deleteMessage.withArgs({
path: trashMailbox.path,
uid: uid
}).yields();
emailSync._imapDeleteMessage({
folder: trashMailbox.path,
uid: uid
}, done);
});
});
describe('_imapListMessages', function() {