Improve mailvelope decryption errors handling, hide encrypted part attachment on successful decryption (#5279)

+ small style improvements
pull/135/merge
Aleksander Machniak 8 years ago
parent a487055c5a
commit 15bd0b51a4

@ -3806,15 +3806,27 @@ function rcube_webmail()
// wrapper for the mailvelope.createDisplayContainer API call // wrapper for the mailvelope.createDisplayContainer API call
this.mailvelope_display_container = function(selector, data, keyring, msgid) this.mailvelope_display_container = function(selector, data, keyring, msgid)
{ {
mailvelope.createDisplayContainer(selector, data, keyring, { showExternalContent: this.env.safemode }).then(function() { var error_handler = function(error) {
$(selector).addClass('mailvelope').children().not('iframe').hide(); // remove mailvelope frame with the error message
$(selector + ' > iframe').remove();
ref.hide_message(msgid); ref.hide_message(msgid);
setTimeout(function() { $(window).resize(); }, 10); ref.display_message(error.message, 'error');
}, function(err) { };
console.error(err);
mailvelope.createDisplayContainer(selector, data, keyring, { showExternalContent: this.env.safemode }).then(function(status) {
if (status.error && status.error.message) {
return error_handler(status.error);
}
ref.hide_message(msgid); ref.hide_message(msgid);
ref.display_message('Message decryption failed: ' + err.message, 'error') $(selector).addClass('mailvelope').children().not('iframe').hide();
});
// on success we can remove encrypted part from the attachments list
if (ref.env.pgp_mime_part)
$('#attach' + ref.env.pgp_mime_part).remove();
setTimeout(function() { $(window).resize(); }, 10);
}, error_handler);
}; };
// subroutine to query keyservers for public keys // subroutine to query keyservers for public keys

@ -189,7 +189,8 @@ function rcmail_message_attachments($attrib)
$filesize = $RCMAIL->message_part_size($attach_prop); $filesize = $RCMAIL->message_part_size($attach_prop);
if ($PRINT_MODE) { if ($PRINT_MODE) {
$ol .= html::tag('li', null, rcube::Q(sprintf("%s (%s)", $filename, $filesize))); $ol .= html::tag('li', array('id' => 'attach' . $attach_prop->mime_id),
rcube::Q(sprintf("%s (%s)", $filename, $filesize)));
} }
else { else {
if ($attrib['maxlength'] && mb_strlen($filename) > $attrib['maxlength']) { if ($attrib['maxlength'] && mb_strlen($filename) > $attrib['maxlength']) {

@ -1085,6 +1085,9 @@ function rcube_init_mail_ui()
}); });
$(window).resize(function() { $(window).resize(function() {
if (!$('#attachment-list > li[id^="attach"]').length)
$('#attachment-list').hide();
var mvlpe = $('#messagebody.mailvelope'); var mvlpe = $('#messagebody.mailvelope');
if (mvlpe.length) { if (mvlpe.length) {
var content = $('#messageframe'), var content = $('#messageframe'),

@ -868,6 +868,10 @@ div.hide-headers {
margin: 8px; margin: 8px;
} }
#messagebody.mailvelope {
margin: 0;
}
#message-objects div, #message-objects div,
#messagebody span.part-notice { #messagebody span.part-notice {
margin: 8px; margin: 8px;

@ -525,7 +525,7 @@ function rcube_mail_ui()
if (mvlpe.length) { if (mvlpe.length) {
var h = $('#messagecontent').length ? var h = $('#messagecontent').length ?
$('#messagecontent').height() - 16 : $('#messagecontent').height() - 16 :
$(window).height() - mvlpe.offset().top - 10; $(window).height() - mvlpe.offset().top - 2;
mvlpe.height(h); mvlpe.height(h);
} }
} }

Loading…
Cancel
Save