mirror of
https://github.com/moparisthebest/mail
synced 2024-12-01 13:22:16 -05:00
do not write angular polluted dto to disk
This commit is contained in:
parent
e3e7962b3e
commit
21428d77ec
@ -811,9 +811,22 @@ define(function(require) {
|
|||||||
|
|
||||||
message.loadingBody = false;
|
message.loadingBody = false;
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
uid: message.uid
|
||||||
|
}, function(error, storedMessages) {
|
||||||
|
if (error) {
|
||||||
|
callback(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storedMessages[0].body = message.body;
|
||||||
|
|
||||||
self._localStoreMessages({
|
self._localStoreMessages({
|
||||||
folder: folder,
|
folder: folder,
|
||||||
emails: [message]
|
emails: storedMessages
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
@ -823,6 +836,7 @@ define(function(require) {
|
|||||||
handleEncryptedContent();
|
handleEncryptedContent();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEncryptedContent() {
|
function handleEncryptedContent() {
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user