mirror of
https://github.com/moparisthebest/mail
synced 2024-12-22 23:38:48 -05:00
Move ignoreUploadOnSent check to emailDao
This commit is contained in:
parent
082cbf192b
commit
16308232ce
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user