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

Show decrypting/parsing errors in mail reader

This commit is contained in:
Tankred Hase 2014-05-12 13:44:02 +02:00
parent 2a1a92f907
commit 99edcee93b
3 changed files with 21 additions and 14 deletions

View File

@ -70,10 +70,13 @@ define(function(require) {
$scope.node = undefined;
});
$scope.$watch('state.mailList.selected.body', function(body) {
var selected = $scope.state.mailList.selected;
$scope.node = undefined; // reset model
if (!body || (body && selected.encrypted && !selected.decrypted)) {
if (!body) {
return;
}
var selected = $scope.state.mailList.selected;
if (selected.encrypted && !selected.decrypted) {
return;
}

View File

@ -398,15 +398,13 @@ define(function(require) {
// get the sender's public key for signature checking
self._keychain.getReceiverPublicKey(message.from[0].address, function(err, senderPublicKey) {
if (err) {
message.decryptingBody = false;
callback(err);
done(err);
return;
}
if (!senderPublicKey) {
// this should only happen if a mail from another channel is in the inbox
message.body = 'Public key for sender not found!';
done();
showError('Public key for sender not found!');
return;
}
@ -414,8 +412,7 @@ define(function(require) {
var encryptedNode = self._emailSync.filterBodyParts(message.bodyParts, 'encrypted')[0];
self._crypto.decrypt(encryptedNode.content, senderPublicKey.publicKey, function(err, decrypted) {
if (err || !decrypted) {
message.body = err.errMsg || err.message;
done();
showError(err.errMsg || err.message);
return;
}
@ -425,9 +422,9 @@ define(function(require) {
// parse the decrpyted raw content in the mailparser
self._mailreader.parse({
bodyParts: [encryptedNode]
}, function(error, parsedBodyParts) {
if (error) {
done(error);
}, function(err, parsedBodyParts) {
if (err) {
showError(err.errMsg || err.message);
return;
}
@ -450,6 +447,12 @@ define(function(require) {
});
});
function showError(msg) {
message.body = msg;
message.decrypted = true; // display error msh in body
done();
}
function done(err) {
message.decryptingBody = false;
callback(err, err ? undefined : message);

View File

@ -994,8 +994,9 @@ define(function(require) {
dao.decryptBody({
message: message
}, function(error, msg) {
expect(error).to.exist;
expect(msg).to.not.exist;
expect(error).to.not.exist;
expect(msg.body).to.equal('asd');
expect(msg).to.exist;
expect(message.decryptingBody).to.be.false;
expect(keychainStub.getReceiverPublicKey.calledOnce).to.be.true;