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:
parent
2a1a92f907
commit
99edcee93b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user