mirror of
https://github.com/moparisthebest/mail
synced 2025-02-18 07:50:34 -05:00
remove [whiteout] filters
This commit is contained in:
parent
ff50eeb862
commit
69a222e46a
@ -20,15 +20,6 @@ define(function(require) {
|
|||||||
// push handler
|
// push handler
|
||||||
if (emailDao) {
|
if (emailDao) {
|
||||||
emailDao.onIncomingMessage = function(email) {
|
emailDao.onIncomingMessage = function(email) {
|
||||||
if (!email.subject) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (email.subject.indexOf(str.subjectPrefix) === -1 ||
|
|
||||||
email.subject === str.subjectPrefix + str.verificationSubject) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
$scope.synchronize(function() {
|
$scope.synchronize(function() {
|
||||||
// show notification
|
// show notification
|
||||||
@ -38,22 +29,6 @@ define(function(require) {
|
|||||||
chrome.notifications.onClicked.addListener(notificationClicked);
|
chrome.notifications.onClicked.addListener(notificationClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
function notificationClicked(uidString) {
|
|
||||||
var email, uid = parseInt(uidString, 10);
|
|
||||||
|
|
||||||
if (isNaN(uid)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
email = _.findWhere(getFolder().messages, {
|
|
||||||
uid: uid
|
|
||||||
});
|
|
||||||
|
|
||||||
if (email) {
|
|
||||||
$scope.select(email);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// scope functions
|
// scope functions
|
||||||
//
|
//
|
||||||
@ -249,6 +224,22 @@ define(function(require) {
|
|||||||
// helper functions
|
// helper functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
function notificationClicked(uidString) {
|
||||||
|
var email, uid = parseInt(uidString, 10);
|
||||||
|
|
||||||
|
if (isNaN(uid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
email = _.findWhere(getFolder().messages, {
|
||||||
|
uid: uid
|
||||||
|
});
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
$scope.select(email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function notificationForEmail(email) {
|
function notificationForEmail(email) {
|
||||||
chrome.notifications.create('' + email.uid, {
|
chrome.notifications.create('' + email.uid, {
|
||||||
type: 'basic',
|
type: 'basic',
|
||||||
|
@ -566,11 +566,13 @@ define(function(require) {
|
|||||||
|
|
||||||
if (verificationMessage) {
|
if (verificationMessage) {
|
||||||
handleVerification(verificationMessage, function(err) {
|
handleVerification(verificationMessage, function(err) {
|
||||||
// TODO: show usable error when the verification failed
|
// eliminate the verification mail if the verification worked, otherwise display an error and it in the mail list
|
||||||
if (err) {
|
if (err) {
|
||||||
self._account.busy = false;
|
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
} else {
|
||||||
|
messages = _.filter(messages, function(message) {
|
||||||
|
return message.subject !== (str.subjectPrefix + str.verificationSubject);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
storeHeaders();
|
storeHeaders();
|
||||||
@ -581,23 +583,12 @@ define(function(require) {
|
|||||||
storeHeaders();
|
storeHeaders();
|
||||||
|
|
||||||
function storeHeaders() {
|
function storeHeaders() {
|
||||||
// eliminate non-whiteout mails
|
|
||||||
messages = _.filter(messages, function(message) {
|
|
||||||
// we don't want to display "[whiteout] "-prefixed mails for now
|
|
||||||
return message.subject.indexOf(str.subjectPrefix) === 0 && message.subject !== (str.subjectPrefix + str.verificationSubject);
|
|
||||||
});
|
|
||||||
|
|
||||||
// no delta, we're done here
|
// no delta, we're done here
|
||||||
if (_.isEmpty(messages)) {
|
if (_.isEmpty(messages)) {
|
||||||
doDeltaF4();
|
doDeltaF4();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out the "[whiteout] " prefix
|
|
||||||
messages.forEach(function(messages) {
|
|
||||||
messages.subject = messages.subject.replace(/^\[whiteout\] /, '');
|
|
||||||
});
|
|
||||||
|
|
||||||
// persist the encrypted message to the local storage
|
// persist the encrypted message to the local storage
|
||||||
self._localStoreMessages({
|
self._localStoreMessages({
|
||||||
folder: folder.path,
|
folder: folder.path,
|
||||||
@ -820,7 +811,11 @@ define(function(require) {
|
|||||||
self._imapDeleteMessage({
|
self._imapDeleteMessage({
|
||||||
folder: options.folder,
|
folder: options.folder,
|
||||||
uid: message.uid
|
uid: message.uid
|
||||||
}, localCallback);
|
}, function() {
|
||||||
|
// if we could successfully not delete the message or not doesn't matter.
|
||||||
|
// just don't show it in whiteout and keep quiet about it
|
||||||
|
localCallback();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1177,8 +1172,7 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var o = {
|
var o = {
|
||||||
path: options.folder,
|
path: options.folder
|
||||||
subject: str.subjectPrefix
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof options.answered !== 'undefined') {
|
if (typeof options.answered !== 'undefined') {
|
||||||
|
@ -35,7 +35,7 @@ define(function(require) {
|
|||||||
to: [{
|
to: [{
|
||||||
address: 'qwe@qwe.de'
|
address: 'qwe@qwe.de'
|
||||||
}],
|
}],
|
||||||
subject: '[whiteout] qweasd',
|
subject: 'qweasd',
|
||||||
body: '-----BEGIN PGP MESSAGE-----\nasd\n-----END PGP MESSAGE-----',
|
body: '-----BEGIN PGP MESSAGE-----\nasd\n-----END PGP MESSAGE-----',
|
||||||
unread: false,
|
unread: false,
|
||||||
answered: false
|
answered: false
|
||||||
@ -51,7 +51,7 @@ define(function(require) {
|
|||||||
}], // list of receivers
|
}], // list of receivers
|
||||||
subject: "[whiteout] New public key uploaded", // Subject line
|
subject: "[whiteout] New public key uploaded", // Subject line
|
||||||
body: 'yadda yadda bla blabla foo bar https://keys.whiteout.io/verify/' + verificationUuid, // plaintext body
|
body: 'yadda yadda bla blabla foo bar https://keys.whiteout.io/verify/' + verificationUuid, // plaintext body
|
||||||
unread: true,
|
unread: false,
|
||||||
answered: false
|
answered: false
|
||||||
};
|
};
|
||||||
corruptedVerificationUuid = 'OMFG_FUCKING_BASTARD_UUID_FROM_HELL!';
|
corruptedVerificationUuid = 'OMFG_FUCKING_BASTARD_UUID_FROM_HELL!';
|
||||||
@ -65,7 +65,7 @@ define(function(require) {
|
|||||||
}], // list of receivers
|
}], // list of receivers
|
||||||
subject: "[whiteout] New public key uploaded", // Subject line
|
subject: "[whiteout] New public key uploaded", // Subject line
|
||||||
body: 'yadda yadda bla blabla foo bar https://keys.whiteout.io/verify/' + corruptedVerificationUuid, // plaintext body
|
body: 'yadda yadda bla blabla foo bar https://keys.whiteout.io/verify/' + corruptedVerificationUuid, // plaintext body
|
||||||
unread: true,
|
unread: false,
|
||||||
answered: false
|
answered: false
|
||||||
};
|
};
|
||||||
dummyDecryptedMail = {
|
dummyDecryptedMail = {
|
||||||
@ -654,8 +654,7 @@ define(function(require) {
|
|||||||
var path = 'FOLDAAAA';
|
var path = 'FOLDAAAA';
|
||||||
|
|
||||||
imapClientStub.search.withArgs({
|
imapClientStub.search.withArgs({
|
||||||
path: path,
|
path: path
|
||||||
subject: '[whiteout] '
|
|
||||||
}).yields();
|
}).yields();
|
||||||
|
|
||||||
dao._imapSearch({
|
dao._imapSearch({
|
||||||
@ -667,7 +666,6 @@ define(function(require) {
|
|||||||
|
|
||||||
imapClientStub.search.withArgs({
|
imapClientStub.search.withArgs({
|
||||||
path: path,
|
path: path,
|
||||||
subject: '[whiteout] ',
|
|
||||||
answered: true
|
answered: true
|
||||||
}).yields();
|
}).yields();
|
||||||
|
|
||||||
@ -681,7 +679,6 @@ define(function(require) {
|
|||||||
|
|
||||||
imapClientStub.search.withArgs({
|
imapClientStub.search.withArgs({
|
||||||
path: path,
|
path: path,
|
||||||
subject: '[whiteout] ',
|
|
||||||
unread: true
|
unread: true
|
||||||
}).yields();
|
}).yields();
|
||||||
|
|
||||||
@ -1794,60 +1791,6 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not fetch non-whitelisted mails', function(done) {
|
|
||||||
var invocations, folder, localListStub, imapSearchStub, imapListMessagesStub, localStoreStub;
|
|
||||||
|
|
||||||
invocations = 0;
|
|
||||||
folder = 'FOLDAAAA';
|
|
||||||
dao._account.folders = [{
|
|
||||||
type: 'Folder',
|
|
||||||
path: folder,
|
|
||||||
messages: []
|
|
||||||
}];
|
|
||||||
|
|
||||||
localListStub = sinon.stub(dao, '_localListMessages').yields(null, []);
|
|
||||||
imapSearchStub = sinon.stub(dao, '_imapSearch');
|
|
||||||
imapSearchStub.withArgs({
|
|
||||||
folder: folder
|
|
||||||
}).yields(null, [nonWhitelistedMail.uid]);
|
|
||||||
imapSearchStub.withArgs({
|
|
||||||
folder: folder,
|
|
||||||
unread: true
|
|
||||||
}).yields(null, []);
|
|
||||||
imapSearchStub.withArgs({
|
|
||||||
folder: folder,
|
|
||||||
answered: true
|
|
||||||
}).yields(null, []);
|
|
||||||
|
|
||||||
imapListMessagesStub = sinon.stub(dao, '_imapListMessages');
|
|
||||||
imapListMessagesStub.withArgs({
|
|
||||||
folder: folder,
|
|
||||||
firstUid: nonWhitelistedMail.uid,
|
|
||||||
lastUid: nonWhitelistedMail.uid
|
|
||||||
}).yields(null, [nonWhitelistedMail]);
|
|
||||||
|
|
||||||
localStoreStub = sinon.stub(dao, '_localStoreMessages');
|
|
||||||
|
|
||||||
dao.sync({
|
|
||||||
folder: folder
|
|
||||||
}, function(err) {
|
|
||||||
expect(err).to.not.exist;
|
|
||||||
|
|
||||||
if (invocations === 0) {
|
|
||||||
expect(dao._account.busy).to.be.true;
|
|
||||||
invocations++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(dao._account.busy).to.be.false;
|
|
||||||
expect(dao._account.folders[0].messages).to.be.empty;
|
|
||||||
expect(localListStub.calledOnce).to.be.true;
|
|
||||||
expect(imapSearchStub.calledThrice).to.be.true;
|
|
||||||
expect(localStoreStub.called).to.be.false;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should error while storing messages from the remote locally', function(done) {
|
it('should error while storing messages from the remote locally', function(done) {
|
||||||
var invocations, folder, localListStub, imapSearchStub, localStoreStub, imapListMessagesStub;
|
var invocations, folder, localListStub, imapSearchStub, localStoreStub, imapListMessagesStub;
|
||||||
|
|
||||||
@ -1896,7 +1839,7 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should verify an authentication mail', function(done) {
|
it('should verify an authentication mail', function(done) {
|
||||||
var invocations, folder, localListStub, imapSearchStub, imapGetStub, imapListMessagesStub, imapDeleteStub;
|
var invocations, folder, localListStub, imapSearchStub, imapGetStub, imapListMessagesStub, imapDeleteStub, localStoreStub;
|
||||||
|
|
||||||
invocations = 0;
|
invocations = 0;
|
||||||
folder = 'FOLDAAAA';
|
folder = 'FOLDAAAA';
|
||||||
@ -1909,20 +1852,29 @@ define(function(require) {
|
|||||||
localListStub = sinon.stub(dao, '_localListMessages').yields(null, []);
|
localListStub = sinon.stub(dao, '_localListMessages').yields(null, []);
|
||||||
|
|
||||||
imapSearchStub = sinon.stub(dao, '_imapSearch');
|
imapSearchStub = sinon.stub(dao, '_imapSearch');
|
||||||
|
|
||||||
imapSearchStub.withArgs({
|
imapSearchStub.withArgs({
|
||||||
folder: folder
|
folder: folder
|
||||||
}).yields(null, [verificationMail.uid]);
|
}).yields(null, [verificationMail.uid]);
|
||||||
|
|
||||||
imapSearchStub.withArgs({
|
imapSearchStub.withArgs({
|
||||||
folder: folder,
|
folder: folder,
|
||||||
unread: true
|
unread: true
|
||||||
}).yields(null, []);
|
}).yields(null, []);
|
||||||
|
|
||||||
imapSearchStub.withArgs({
|
imapSearchStub.withArgs({
|
||||||
folder: folder,
|
folder: folder,
|
||||||
answered: true
|
answered: true
|
||||||
}).yields(null, []);
|
}).yields(null, []);
|
||||||
|
|
||||||
imapListMessagesStub = sinon.stub(dao, '_imapListMessages').yields(null, [verificationMail]);
|
imapListMessagesStub = sinon.stub(dao, '_imapListMessages').yields(null, [verificationMail]);
|
||||||
|
|
||||||
imapGetStub = sinon.stub(dao, '_imapStreamText').yields(null);
|
imapGetStub = sinon.stub(dao, '_imapStreamText').yields(null);
|
||||||
|
|
||||||
keychainStub.verifyPublicKey.withArgs(verificationUuid).yields();
|
keychainStub.verifyPublicKey.withArgs(verificationUuid).yields();
|
||||||
|
|
||||||
|
localStoreStub = sinon.stub(dao, '_localStoreMessages');
|
||||||
|
|
||||||
imapDeleteStub = sinon.stub(dao, '_imapDeleteMessage').withArgs({
|
imapDeleteStub = sinon.stub(dao, '_imapDeleteMessage').withArgs({
|
||||||
folder: folder,
|
folder: folder,
|
||||||
uid: verificationMail.uid
|
uid: verificationMail.uid
|
||||||
@ -1946,13 +1898,14 @@ define(function(require) {
|
|||||||
expect(imapGetStub.calledOnce).to.be.true;
|
expect(imapGetStub.calledOnce).to.be.true;
|
||||||
expect(keychainStub.verifyPublicKey.calledOnce).to.be.true;
|
expect(keychainStub.verifyPublicKey.calledOnce).to.be.true;
|
||||||
expect(imapDeleteStub.calledOnce).to.be.true;
|
expect(imapDeleteStub.calledOnce).to.be.true;
|
||||||
|
expect(localStoreStub.calledOnce).to.be.false;
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail during deletion of an authentication mail', function(done) {
|
it('should not care abouta failed deletion of an authentication mail', function(done) {
|
||||||
var invocations, folder, localListStub, imapSearchStub, imapGetStub, imapListMessagesStub, imapDeleteStub;
|
var invocations, folder, localListStub, localStoreStub, imapSearchStub, imapGetStub, imapListMessagesStub, imapDeleteStub;
|
||||||
|
|
||||||
invocations = 0;
|
invocations = 0;
|
||||||
folder = 'FOLDAAAA';
|
folder = 'FOLDAAAA';
|
||||||
@ -1981,6 +1934,12 @@ define(function(require) {
|
|||||||
keychainStub.verifyPublicKey.withArgs(verificationUuid).yields();
|
keychainStub.verifyPublicKey.withArgs(verificationUuid).yields();
|
||||||
imapDeleteStub = sinon.stub(dao, '_imapDeleteMessage').yields({});
|
imapDeleteStub = sinon.stub(dao, '_imapDeleteMessage').yields({});
|
||||||
|
|
||||||
|
localStoreStub = sinon.stub(dao, '_localStoreMessages');
|
||||||
|
localStoreStub.withArgs({
|
||||||
|
folder: folder,
|
||||||
|
emails: [verificationMail]
|
||||||
|
}).yields();
|
||||||
|
|
||||||
dao.sync({
|
dao.sync({
|
||||||
folder: folder
|
folder: folder
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@ -1992,11 +1951,12 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(err).to.exist;
|
expect(err).to.not.exist;
|
||||||
expect(dao._account.busy).to.be.false;
|
expect(dao._account.busy).to.be.false;
|
||||||
expect(dao._account.folders[0].messages).to.be.empty;
|
expect(dao._account.folders[0].messages).to.be.empty;
|
||||||
expect(localListStub.calledOnce).to.be.true;
|
expect(localListStub.calledOnce).to.be.true;
|
||||||
expect(imapSearchStub.calledOnce).to.be.true;
|
expect(localStoreStub.called).to.be.false;
|
||||||
|
expect(imapSearchStub.calledThrice).to.be.true;
|
||||||
expect(imapGetStub.calledOnce).to.be.true;
|
expect(imapGetStub.calledOnce).to.be.true;
|
||||||
expect(keychainStub.verifyPublicKey.calledOnce).to.be.true;
|
expect(keychainStub.verifyPublicKey.calledOnce).to.be.true;
|
||||||
expect(imapDeleteStub.calledOnce).to.be.true;
|
expect(imapDeleteStub.calledOnce).to.be.true;
|
||||||
@ -2006,7 +1966,7 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail during verifying authentication', function(done) {
|
it('should fail during verifying authentication', function(done) {
|
||||||
var invocations, folder, localListStub, imapSearchStub, imapGetStub, imapListMessagesStub, imapDeleteStub;
|
var invocations, folder, localListStub, imapSearchStub, localStoreStub, imapGetStub, imapListMessagesStub, imapDeleteStub;
|
||||||
|
|
||||||
invocations = 0;
|
invocations = 0;
|
||||||
folder = 'FOLDAAAA';
|
folder = 'FOLDAAAA';
|
||||||
@ -2037,6 +1997,12 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
imapDeleteStub = sinon.stub(dao, '_imapDeleteMessage').yields({});
|
imapDeleteStub = sinon.stub(dao, '_imapDeleteMessage').yields({});
|
||||||
|
|
||||||
|
localStoreStub = sinon.stub(dao, '_localStoreMessages');
|
||||||
|
localStoreStub.withArgs({
|
||||||
|
folder: folder,
|
||||||
|
emails: [verificationMail]
|
||||||
|
}).yields();
|
||||||
|
|
||||||
dao.sync({
|
dao.sync({
|
||||||
folder: folder
|
folder: folder
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@ -2048,11 +2014,18 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(err).to.exist;
|
if (invocations === 1) {
|
||||||
|
expect(err).to.exist;
|
||||||
|
expect(dao._account.busy).to.be.true;
|
||||||
|
invocations++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(err).to.not.exist;
|
||||||
expect(dao._account.busy).to.be.false;
|
expect(dao._account.busy).to.be.false;
|
||||||
expect(dao._account.folders[0].messages).to.be.empty;
|
expect(dao._account.folders[0].messages).to.not.be.empty;
|
||||||
expect(localListStub.calledOnce).to.be.true;
|
expect(localListStub.calledOnce).to.be.true;
|
||||||
expect(imapSearchStub.calledOnce).to.be.true;
|
expect(imapSearchStub.calledThrice).to.be.true;
|
||||||
expect(imapGetStub.calledOnce).to.be.true;
|
expect(imapGetStub.calledOnce).to.be.true;
|
||||||
expect(keychainStub.verifyPublicKey.calledOnce).to.be.true;
|
expect(keychainStub.verifyPublicKey.calledOnce).to.be.true;
|
||||||
expect(imapDeleteStub.called).to.be.false;
|
expect(imapDeleteStub.called).to.be.false;
|
||||||
|
Loading…
Reference in New Issue
Block a user