1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 17:02:17 -05:00

Move ignoreUploadOnSent check to emailDao

This commit is contained in:
Felix Hammerl 2014-11-12 16:41:40 +01:00
parent 082cbf192b
commit 16308232ce
4 changed files with 42 additions and 8 deletions

View File

@ -10,6 +10,7 @@ exports.config = {
settingsUrl: 'https://settings.whiteout.io/autodiscovery/',
wmailDomain: 'wmail.io',
oauthDomains: [/\.gmail\.com$/, /\.googlemail\.com$/],
ignoreUploadOnSentDomains: [/\.gmail\.com$/, /\.googlemail\.com$/],
serverPrivateKeyId: 'EE342F0DDBB0F3BE',
symKeySize: 256,
symIvSize: 96,

View File

@ -278,17 +278,11 @@ ctrl.onConnect = function(callback) {
imapClient.onCert = ctrl._auth.handleCertificateUpdate.bind(ctrl._auth, 'imap', ctrl.onConnect, ctrl.onError);
pgpMailer.onCert = ctrl._auth.handleCertificateUpdate.bind(ctrl._auth, 'smtp', ctrl.onConnect, ctrl.onError);
// TODO: remove provider here
// after-setup configuration depending on the provider:
// gmail does not require you to upload to the sent items folder
// after successful sending, whereas most other providers do
ctrl._emailDao.ignoreUploadOnSent = !!(config[ctrl._auth.provider] && config[ctrl._auth.provider].ignoreUploadOnSent);
// connect to clients
ctrl._emailDao.onConnect({
imapClient: imapClient,
pgpMailer: pgpMailer
pgpMailer: pgpMailer,
ignoreUploadOnSent: ctrl._emailDao.checkIgnoreUploadOnSent(credentials.imap.host)
}, callback);
}

View File

@ -1132,6 +1132,9 @@ EmailDAO.prototype.onConnect = function(options, callback) {
self._imapClient = options.imapClient;
self._pgpMailer = options.pgpMailer;
// gmail does not require you to upload to the sent items folder after successful sending, whereas most other providers do
self.ignoreUploadOnSent = !!options.ignoreUploadOnSent;
self._imapClient.login(function(err) {
self._account.loggingIn = false;
@ -1776,6 +1779,29 @@ EmailDAO.prototype._uploadToSent = function(options, callback) {
//
//
// External Heler Methods
//
//
/**
* Checks whether we need to upload to the sent folder after sending an email.
*
* @param {String} hostname The hostname to check
* @return {Boolean} true if upload can be ignored, otherwise false
*/
EmailDAO.prototype.checkIgnoreUploadOnSent = function(hostname) {
for (var i = 0; i < config.ignoreUploadOnSentDomains.length; i++) {
if (config.ignoreUploadOnSentDomains[i].test(hostname)) {
return true;
}
}
return false;
};
//
//
// Helper Functions

View File

@ -1854,6 +1854,7 @@ describe('Email DAO unit tests', function() {
}, function(err) {
expect(err).to.not.exist;
expect(dao.ignoreUploadOnSent).to.be.false;
expect(imapClientStub.login.calledOnce).to.be.true;
expect(initFoldersStub.calledOnce).to.be.true;
expect(imapClientStub.mailboxCache).to.deep.equal({
@ -2478,5 +2479,17 @@ describe('Email DAO unit tests', function() {
});
});
});
describe('#checkIgnoreUploadOnSent', function() {
it('should ignore upload on gmail', function() {
expect(dao.checkIgnoreUploadOnSent('bla.gmail.com')).to.be.true;
expect(dao.checkIgnoreUploadOnSent('bla.googlemail.com')).to.be.true;
});
it('should not ignore upload on other domain', function() {
expect(dao.checkIgnoreUploadOnSent('imap.foo.com')).to.be.false;
});
});
});
});