mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-09 01:17:04 +03:00
Cleanup pgp decrypt code and show green when decrypted
This commit is contained in:
parent
b2a492bdab
commit
f4bed88e39
8 changed files with 280 additions and 302 deletions
|
|
@ -75,10 +75,11 @@ export class MessageModel extends AbstractModel {
|
|||
hasExternals: false,
|
||||
|
||||
pgpSigned: null,
|
||||
pgpEncrypted: null,
|
||||
isPgpEncrypted: false,
|
||||
pgpVerified: null,
|
||||
|
||||
pgpEncrypted: null,
|
||||
pgpDecrypted: false,
|
||||
|
||||
readReceipt: '',
|
||||
|
||||
hasUnseenSubMessage: false,
|
||||
|
|
@ -153,10 +154,11 @@ export class MessageModel extends AbstractModel {
|
|||
this.attachments(new AttachmentCollectionModel);
|
||||
|
||||
this.pgpSigned(null);
|
||||
this.pgpEncrypted(null);
|
||||
this.isPgpEncrypted(false);
|
||||
this.pgpVerified(null);
|
||||
|
||||
this.pgpEncrypted(null);
|
||||
this.pgpDecrypted(false);
|
||||
|
||||
this.priority(MessagePriority.Normal);
|
||||
this.readReceipt('');
|
||||
|
||||
|
|
@ -472,6 +474,7 @@ export class MessageModel extends AbstractModel {
|
|||
initView() {
|
||||
// init BlockquoteSwitcher
|
||||
this.body.querySelectorAll('blockquote:not(.rl-bq-switcher)').forEach(node => {
|
||||
node.removeAttribute('style')
|
||||
if (node.textContent.trim() && !node.parentNode.closest('blockquote')) {
|
||||
let h = node.clientHeight || getRealHeight(node);
|
||||
if (0 === h || 100 < h) {
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ export const MessageUserStore = new class {
|
|||
} else {
|
||||
body = Element.fromHTML('<div id="' + id + '" hidden="" class="b-text-part '
|
||||
+ (message.pgpSigned() ? ' openpgp-signed' : '')
|
||||
+ (message.isPgpEncrypted() ? ' openpgp-encrypted' : '')
|
||||
+ (message.pgpEncrypted() ? ' openpgp-encrypted' : '')
|
||||
+ '">'
|
||||
+ '</div>');
|
||||
message.body = body;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ export const
|
|||
}
|
||||
} else {
|
||||
body.classList.add('mailvelope');
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,57 @@ html.rl-no-preview-pane {
|
|||
}
|
||||
}
|
||||
|
||||
#messageItem {
|
||||
.openpgp-control {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
span {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.encrypted {
|
||||
border: 1px dashed #18F;
|
||||
color: #18F;
|
||||
}
|
||||
&.signed {
|
||||
border: 1px dashed #FA0;
|
||||
color: #FA0;
|
||||
}
|
||||
|
||||
&.success {
|
||||
border-color: #090;
|
||||
color: #090;
|
||||
}
|
||||
&.error {
|
||||
border-color: #F00;
|
||||
color: #F00;
|
||||
}
|
||||
&.error button,
|
||||
&.success button {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.b-text-part > iframe {
|
||||
min-height: 50vh;
|
||||
}
|
||||
|
||||
.thread-controls {
|
||||
.dropdown-toggle {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
&.open .dropdown-toggle {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#messageItem {
|
||||
|
||||
color: #000;
|
||||
height: 100%;
|
||||
|
|
@ -284,7 +334,6 @@ html.rl-no-preview-pane {
|
|||
text-align: center;
|
||||
cursor: pointer;
|
||||
margin: 2em 0 10px;
|
||||
|
||||
opacity: 0.5;
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
|
|
@ -294,6 +343,7 @@ html.rl-no-preview-pane {
|
|||
.b-text-part {
|
||||
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
|
||||
div[data-x-div-type=html] {
|
||||
height: 100%;
|
||||
|
|
@ -316,6 +366,7 @@ html.rl-no-preview-pane {
|
|||
|
||||
blockquote {
|
||||
border-left: 2px solid #000;
|
||||
opacity: 0.8;
|
||||
padding: 0 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
|
@ -386,7 +437,6 @@ html.rl-no-preview-pane {
|
|||
|
||||
&.plain {
|
||||
|
||||
padding: 15px;
|
||||
white-space: pre-wrap;
|
||||
font-family: var(--fontMono);
|
||||
|
||||
|
|
@ -397,21 +447,6 @@ html.rl-no-preview-pane {
|
|||
display: block;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left: 2px solid blue;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
blockquote blockquote {
|
||||
border-left: 2px solid green;
|
||||
color: green;
|
||||
}
|
||||
|
||||
blockquote blockquote blockquote {
|
||||
border-left: 2px solid red;
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -430,56 +465,6 @@ html.rl-no-preview-pane {
|
|||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
.openpgp-control {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
span {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.encrypted {
|
||||
border: 1px dashed #18F;
|
||||
color: #18F;
|
||||
}
|
||||
&.signed {
|
||||
border: 1px dashed #FA0;
|
||||
color: #FA0;
|
||||
}
|
||||
|
||||
&.success {
|
||||
border-color: #090;
|
||||
color: #090;
|
||||
}
|
||||
&.error {
|
||||
border-color: #F00;
|
||||
color: #F00;
|
||||
}
|
||||
&.error button,
|
||||
&.success button {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.b-text-part > iframe {
|
||||
min-height: 50vh;
|
||||
}
|
||||
|
||||
.thread-controls {
|
||||
.dropdown-toggle {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
&.open .dropdown-toggle {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
html.rl-no-preview-pane .messageView {
|
||||
|
|
|
|||
|
|
@ -583,7 +583,9 @@ export class MailMessageView extends AbstractViewRight {
|
|||
pgpDecrypt() {
|
||||
const oMessage = currentMessage();
|
||||
PgpUserStore.decrypt(oMessage).then(result => {
|
||||
if (result && result.data) {
|
||||
if (result) {
|
||||
oMessage.pgpDecrypted(true);
|
||||
if (result.data) {
|
||||
MimeToMessage(result.data, oMessage);
|
||||
oMessage.html() ? oMessage.viewHtml() : oMessage.viewPlain();
|
||||
if (result.signatures && result.signatures.length) {
|
||||
|
|
@ -594,6 +596,7 @@ export class MailMessageView extends AbstractViewRight {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ class Message implements \JsonSerializable
|
|||
$aThreads = array(),
|
||||
|
||||
$aPgpSigned = null,
|
||||
$aPgpEncrypted = null,
|
||||
$bPgpEncrypted = false;
|
||||
$aPgpEncrypted = null;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
|
|
@ -106,11 +105,6 @@ class Message implements \JsonSerializable
|
|||
return $this->aPgpEncrypted;
|
||||
}
|
||||
|
||||
public function isPgpEncrypted() : bool
|
||||
{
|
||||
return $this->bPgpEncrypted || $this->aPgpEncrypted;
|
||||
}
|
||||
|
||||
public function Folder() : string
|
||||
{
|
||||
return $this->sFolder;
|
||||
|
|
@ -491,10 +485,6 @@ class Message implements \JsonSerializable
|
|||
$oMessage->sInReplyTo = $oFetchResponse->GetFetchEnvelopeValue(8, '');
|
||||
}
|
||||
|
||||
// Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"
|
||||
$oMessage->bPgpEncrypted = ('multipart/encrypted' === \strtolower($oMessage->sContentType)
|
||||
&& 'application/pgp-encrypted' === \strtolower($oHeaders->ParameterValue(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, \MailSo\Mime\Enumerations\Parameter::PROTOCOL)));
|
||||
|
||||
if ($oBodyStructure)
|
||||
{
|
||||
$gEncryptedParts = $oBodyStructure->SearchByContentType('multipart/encrypted');
|
||||
|
|
@ -573,12 +563,6 @@ class Message implements \JsonSerializable
|
|||
];
|
||||
}
|
||||
|
||||
if ('text/html' === $oPart->ContentType())
|
||||
{
|
||||
$aHtmlParts[] = $sText;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (\str_contains($sText, '-----BEGIN PGP MESSAGE-----'))
|
||||
{
|
||||
$keyIds = [];
|
||||
|
|
@ -592,6 +576,12 @@ class Message implements \JsonSerializable
|
|||
];
|
||||
}
|
||||
|
||||
if ('text/html' === $oPart->ContentType())
|
||||
{
|
||||
$aHtmlParts[] = $sText;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oPart->IsFlowedFormat())
|
||||
{
|
||||
$sText = Utils::DecodeFlowedFormat($sText);
|
||||
|
|
@ -605,9 +595,7 @@ class Message implements \JsonSerializable
|
|||
$oMessage->sHtml = \implode('<br>', $aHtmlParts);
|
||||
$oMessage->sPlain = \trim(\implode("\n", $aPlainParts));
|
||||
|
||||
$oMessage->bPgpEncrypted = !$oMessage->bPgpEncrypted && false !== \stripos($oMessage->sPlain, '-----BEGIN PGP MESSAGE-----');
|
||||
|
||||
unset($aHtmlParts, $aPlainParts, $aMatch);
|
||||
unset($aHtmlParts, $aPlainParts);
|
||||
}
|
||||
|
||||
$gAttachmentsParts = $oBodyStructure->SearchAttachmentsParts();
|
||||
|
|
|
|||
|
|
@ -211,7 +211,6 @@ trait Response
|
|||
$mResult['Plain'] = $mResponse->Plain();
|
||||
|
||||
// $this->GetCapa(Capa::OPEN_PGP) || $this->GetCapa(Capa::GNUPG)
|
||||
$mResult['isPgpEncrypted'] = $mResponse->isPgpEncrypted();
|
||||
$mResult['PgpSigned'] = $mResponse->PgpSigned();
|
||||
$mResult['PgpEncrypted'] = $mResponse->PgpEncrypted();
|
||||
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="openpgp-control encrypted" data-bind="visible: message().pgpEncrypted() || message().isPgpEncrypted()">
|
||||
<div class="openpgp-control encrypted" data-bind="visible: message().pgpEncrypted(), css: {'success': message().pgpDecrypted()}">
|
||||
<span data-icon="🔒" data-i18n="OPENPGP/ENCRYPTED_MESSAGE"></span>
|
||||
<button class="btn" data-bind="visible: pgpSupported, click: pgpDecrypt" data-i18n="OPENPGP/BUTTON_DECRYPT"></button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue