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

[WO-939] Fix TLS cert rejection bug

This commit is contained in:
Felix Hammerl 2015-04-27 18:15:36 +02:00
parent d36ddcef7f
commit 55add6a6d3
5 changed files with 24 additions and 31 deletions

View File

@ -11,7 +11,7 @@ var NOTIFICATION_SENT_TIMEOUT = 2000;
// Controller
//
var NavigationCtrl = function($scope, $location, $q, $timeout, account, email, outbox, notification, appConfig, dialog, dummy, privateKey, axe) {
var NavigationCtrl = function($scope, $location, $q, $timeout, account, email, outbox, notification, status, appConfig, dialog, dummy, privateKey, axe) {
if (!$location.search().dev && !account.isLoggedIn()) {
$location.path('/'); // init app
return;
@ -90,10 +90,10 @@ var NavigationCtrl = function($scope, $location, $q, $timeout, account, email, o
// scope functions
//
$scope.onOutboxUpdate = function(err, count) {
$scope.onOutboxUpdate = function(err) {
if (err) {
dialog.error(err);
return;
axe.error('Sending from outbox failed: ' + err.message);
status.update('Error sending messages...');
}
// update the outbox mail count
@ -106,8 +106,6 @@ var NavigationCtrl = function($scope, $location, $q, $timeout, account, email, o
return;
}
ob.count = count;
return $q(function(resolve) {
resolve();

View File

@ -809,7 +809,7 @@ Email.prototype.refreshOutbox = function() {
outbox.messages.splice(index, 1);
});
updateUnreadCount(outbox); // update the unread count
updateUnreadCount(outbox, true); // update the unread count, count all messages
});
};
@ -1731,16 +1731,13 @@ Email.prototype.isOnline = function() {
/**
* Updates a folder's unread count:
* - For the outbox, that's the total number of messages,
* - For every other folder, it's the number of unread messages
* - For the outbox, that's the total number of messages (countAllMessages === true),
* - For every other folder, it's the number of unread messages (countAllMessages === falsy)
*/
function updateUnreadCount(folder) {
var allMsgs = folder.messages.length,
unreadMsgs = _.filter(folder.messages, function(msg) {
return msg.unread;
}).length;
folder.count = folder.path === config.outboxMailboxPath ? allMsgs : unreadMsgs;
function updateUnreadCount(folder, countAllMessages) {
folder.count = countAllMessages ? folder.messages.length : _.filter(folder.messages, function(msg) {
return msg.unread;
}).length;
}
/**

View File

@ -124,8 +124,7 @@ Outbox.prototype.put = function(mail) {
* @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of pending mails.
*/
Outbox.prototype._processOutbox = function(callback) {
var self = this,
unsentMails = 0;
var self = this;
// also, if a _processOutbox call is still in progress, ignore it.
if (self._outboxBusy) {
@ -138,7 +137,6 @@ Outbox.prototype._processOutbox = function(callback) {
self._devicestorage.listItems(outboxDb).then(function(pendingMails) {
// if we're not online, don't even bother sending mails.
if (!self._emailDao._account.online || _.isEmpty(pendingMails)) {
unsentMails = pendingMails.length;
return;
}
@ -154,7 +152,7 @@ Outbox.prototype._processOutbox = function(callback) {
}).then(function() {
self._outboxBusy = false;
callback(null, unsentMails);
callback();
}).catch(function(err) {
self._outboxBusy = false;

View File

@ -75,17 +75,20 @@ describe('Navigation Controller unit test', function() {
});
describe('empty outbox', function() {
it('should work', function() {
var callback;
it('should work', function(done) {
var onOutboxUpdate;
expect(outboxBoMock.startChecking.callCount).to.equal(1);
outboxBoMock.startChecking.calledWith(sinon.match(function(cb) {
callback = cb;
onOutboxUpdate = cb;
}));
callback(null, 5);
expect(outboxFolder.count).to.equal(5);
emailDaoMock.refreshOutbox.returns(resolves());
onOutboxUpdate().then(function() {
expect(emailDaoMock.refreshOutbox.calledOnce).to.be.true;
done();
});
});
});

View File

@ -263,10 +263,8 @@ describe('Outbox unit test', function() {
devicestorageStub.removeList.returns(resolves());
function onOutboxUpdate(err, count) {
function onOutboxUpdate(err) {
expect(err).to.not.exist;
expect(count).to.equal(0);
expect(outbox._outboxBusy).to.be.false;
expect(emailDaoStub.sendEncrypted.callCount).to.equal(2);
expect(emailDaoStub.sendPlaintext.callCount).to.equal(2);
@ -284,9 +282,8 @@ describe('Outbox unit test', function() {
emailDaoStub._account.online = false;
devicestorageStub.listItems.returns(resolves([{}]));
outbox._processOutbox(function(err, count) {
outbox._processOutbox(function(err) {
expect(err).to.not.exist;
expect(count).to.equal(1);
expect(devicestorageStub.listItems.callCount).to.equal(1);
expect(outbox._outboxBusy).to.be.false;
done();