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

do not write angular polluted dto to disk

This commit is contained in:
Felix Hammerl 2014-02-24 17:37:23 +01:00
parent e3e7962b3e
commit 21428d77ec
2 changed files with 27 additions and 23 deletions

View File

@ -811,16 +811,30 @@ define(function(require) {
message.loadingBody = false; message.loadingBody = false;
self._localStoreMessages({ // do not write the object from the object used by angular to the disk, instead
// do a short round trip and write back the unpolluted object
self._localListMessages({
folder: folder, folder: folder,
emails: [message] uid: message.uid
}, function(error) { }, function(error, storedMessages) {
if (error) { if (error) {
callback(error); callback(error);
return; return;
} }
handleEncryptedContent(); storedMessages[0].body = message.body;
self._localStoreMessages({
folder: folder,
emails: storedMessages
}, function(error) {
if (error) {
callback(error);
return;
}
handleEncryptedContent();
});
}); });
}); });
} }

View File

@ -994,7 +994,6 @@ define(function(require) {
body: body body: body
}]); }]);
dao.getBody({ dao.getBody({
message: message, message: message,
folder: folder folder: folder
@ -1027,7 +1026,7 @@ define(function(require) {
localListStub = sinon.stub(dao, '_localListMessages').withArgs({ localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder, folder: folder,
uid: uid uid: uid
}).yieldsAsync(null, [{}]); }).yieldsAsync(null, [message]);
localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({ localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({
folder: folder, folder: folder,
@ -1056,7 +1055,7 @@ define(function(require) {
expect(msg.encrypted).to.be.false; expect(msg.encrypted).to.be.false;
expect(msg.loadingBody).to.be.false; expect(msg.loadingBody).to.be.false;
expect(localListStub.calledOnce).to.be.true; expect(localListStub.calledTwice).to.be.true;
expect(imapStreamStub.calledOnce).to.be.true; expect(imapStreamStub.calledOnce).to.be.true;
expect(localStoreStub.calledOnce).to.be.true; expect(localStoreStub.calledOnce).to.be.true;
@ -1078,7 +1077,7 @@ define(function(require) {
localListStub = sinon.stub(dao, '_localListMessages').withArgs({ localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder, folder: folder,
uid: uid uid: uid
}).yieldsAsync(null, [{}]); }).yieldsAsync(null, [message]);
localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({ localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({
folder: folder, folder: folder,
@ -1108,7 +1107,7 @@ define(function(require) {
expect(msg.decrypted).to.be.false; expect(msg.decrypted).to.be.false;
expect(msg.loadingBody).to.be.false; expect(msg.loadingBody).to.be.false;
expect(localListStub.calledOnce).to.be.true; expect(localListStub.calledTwice).to.be.true;
expect(imapStreamStub.calledOnce).to.be.true; expect(imapStreamStub.calledOnce).to.be.true;
expect(localStoreStub.calledOnce).to.be.true; expect(localStoreStub.calledOnce).to.be.true;
@ -1121,33 +1120,27 @@ define(function(require) {
var message, uid, folder, body, localListStub, localStoreStub, imapStreamStub; var message, uid, folder, body, localListStub, localStoreStub, imapStreamStub;
folder = 'asdasdasdasdasd'; folder = 'asdasdasdasdasd';
body = 'THIS IS THE BODY';
uid = 1234; uid = 1234;
message = { message = {
uid: uid uid: uid
}; };
localListStub = sinon.stub(dao, '_localListMessages').withArgs({ localListStub = sinon.stub(dao, '_localListMessages').yieldsAsync(null, [message]);
folder: folder, localStoreStub = sinon.stub(dao, '_localStoreMessages').yieldsAsync({});
uid: uid
}).yields(null, [{}]);
imapStreamStub = sinon.stub(dao, '_imapStreamText', function(opts, cb) { imapStreamStub = sinon.stub(dao, '_imapStreamText', function(opts, cb) {
message.body = body; message.body = body;
cb(); cb();
}); });
localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({
folder: folder,
emails: [message]
}).yields({});
dao.getBody({ dao.getBody({
message: message, message: message,
folder: folder folder: folder
}, function(err, msg) { }, function(err, msg) {
expect(err).to.exist; expect(err).to.exist;
expect(msg).to.not.exist; expect(msg).to.not.exist;
expect(localListStub.calledOnce).to.be.true; expect(localListStub.calledTwice).to.be.true;
expect(imapStreamStub.calledOnce).to.be.true; expect(imapStreamStub.calledOnce).to.be.true;
expect(localStoreStub.calledOnce).to.be.true; expect(localStoreStub.calledOnce).to.be.true;
@ -1166,10 +1159,7 @@ define(function(require) {
uid: uid uid: uid
}; };
localListStub = sinon.stub(dao, '_localListMessages').withArgs({ localListStub = sinon.stub(dao, '_localListMessages').yields(null, [{}]);
folder: folder,
uid: uid
}).yields(null, [{}]);
imapStreamStub = sinon.stub(dao, '_imapStreamText', function(opts, cb) { imapStreamStub = sinon.stub(dao, '_imapStreamText', function(opts, cb) {
message.body = body; message.body = body;