1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 18:32:20 -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;
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,
emails: [message]
}, function(error) {
uid: message.uid
}, function(error, storedMessages) {
if (error) {
callback(error);
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
}]);
dao.getBody({
message: message,
folder: folder
@ -1027,7 +1026,7 @@ define(function(require) {
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder,
uid: uid
}).yieldsAsync(null, [{}]);
}).yieldsAsync(null, [message]);
localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({
folder: folder,
@ -1056,7 +1055,7 @@ define(function(require) {
expect(msg.encrypted).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(localStoreStub.calledOnce).to.be.true;
@ -1078,7 +1077,7 @@ define(function(require) {
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder,
uid: uid
}).yieldsAsync(null, [{}]);
}).yieldsAsync(null, [message]);
localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({
folder: folder,
@ -1108,7 +1107,7 @@ define(function(require) {
expect(msg.decrypted).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(localStoreStub.calledOnce).to.be.true;
@ -1121,33 +1120,27 @@ define(function(require) {
var message, uid, folder, body, localListStub, localStoreStub, imapStreamStub;
folder = 'asdasdasdasdasd';
body = 'THIS IS THE BODY';
uid = 1234;
message = {
uid: uid
};
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder,
uid: uid
}).yields(null, [{}]);
localListStub = sinon.stub(dao, '_localListMessages').yieldsAsync(null, [message]);
localStoreStub = sinon.stub(dao, '_localStoreMessages').yieldsAsync({});
imapStreamStub = sinon.stub(dao, '_imapStreamText', function(opts, cb) {
message.body = body;
cb();
});
localStoreStub = sinon.stub(dao, '_localStoreMessages').withArgs({
folder: folder,
emails: [message]
}).yields({});
dao.getBody({
message: message,
folder: folder
}, function(err, msg) {
expect(err).to.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(localStoreStub.calledOnce).to.be.true;
@ -1166,10 +1159,7 @@ define(function(require) {
uid: uid
};
localListStub = sinon.stub(dao, '_localListMessages').withArgs({
folder: folder,
uid: uid
}).yields(null, [{}]);
localListStub = sinon.stub(dao, '_localListMessages').yields(null, [{}]);
imapStreamStub = sinon.stub(dao, '_imapStreamText', function(opts, cb) {
message.body = body;