mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Changes for #89
This part fetches the required message parts for pgp verification.
This commit is contained in:
parent
638128ff93
commit
fde44c0102
3 changed files with 66 additions and 66 deletions
|
|
@ -100,7 +100,7 @@ export class MessageModel extends AbstractModel {
|
||||||
hasImages: false,
|
hasImages: false,
|
||||||
hasExternals: false,
|
hasExternals: false,
|
||||||
|
|
||||||
pgpSigned: null, // { BodyPartId: "1", SigPartId: "2", MicAlg: "pgp-sha256" }
|
pgpSigned: null,
|
||||||
isPgpEncrypted: false,
|
isPgpEncrypted: false,
|
||||||
pgpSignedVerifyStatus: SignedVerifyStatus.None,
|
pgpSignedVerifyStatus: SignedVerifyStatus.None,
|
||||||
pgpSignedVerifyUser: '',
|
pgpSignedVerifyUser: '',
|
||||||
|
|
@ -643,4 +643,29 @@ export class MessageModel extends AbstractModel {
|
||||||
this.isReadReceipt()
|
this.isReadReceipt()
|
||||||
].join(',');
|
].join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pgpDecrypt() {
|
||||||
|
// const message = self.message();
|
||||||
|
// message && pgpClickHelper(message.body, message.plain(), message.getEmails(['from', 'to', 'cc']));
|
||||||
|
/*
|
||||||
|
pgpEncrypted: () => PgpUserStore.openpgp
|
||||||
|
&& MessageUserStore.message() && MessageUserStore.message().isPgpEncrypted(),
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
pgpVerify() {
|
||||||
|
let params = this.pgpSigned(); // { BodyPartId: "1", SigPartId: "2", MicAlg: "pgp-sha256" }
|
||||||
|
if (params) {
|
||||||
|
params.Folder = this.folder;
|
||||||
|
params.Uid = this.uid;
|
||||||
|
rl.app.Remote.post('PgpVerify', null, params)
|
||||||
|
.then(data => {
|
||||||
|
console.dir(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.dir(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,65 +42,6 @@ import { AbstractViewRight } from 'Knoin/AbstractViews';
|
||||||
|
|
||||||
import { PgpUserStore } from 'Stores/User/Pgp';
|
import { PgpUserStore } from 'Stores/User/Pgp';
|
||||||
|
|
||||||
function controlsHelper(dom, verControl, success, title, text)
|
|
||||||
{
|
|
||||||
dom.classList.toggle('error', !success);
|
|
||||||
dom.classList.toggle('success', success);
|
|
||||||
// verControl.classList.toggle('error', !success);
|
|
||||||
// verControl.classList.toggle('success', success);
|
|
||||||
dom.title = verControl.title = title;
|
|
||||||
|
|
||||||
if (undefined !== text) {
|
|
||||||
dom.textContent = text.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pgpClickHelper(dom, armoredMessage) {
|
|
||||||
if (dom.classList.contains('success') || dom.classList.contains('error')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let message = null;
|
|
||||||
try {
|
|
||||||
message = PgpUserStore.openpgp.cleartext.readArmored(armoredMessage);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message && message.getText && message.verify) {
|
|
||||||
PgpUserStore.verifyMessage(message, (validKey, signingKeyIds) => {
|
|
||||||
console.dir([validKey, signingKeyIds]);
|
|
||||||
/*
|
|
||||||
if (validKey) {
|
|
||||||
controlsHelper(
|
|
||||||
dom,
|
|
||||||
this,
|
|
||||||
true,
|
|
||||||
i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
|
||||||
USER: validKey.user + ' (' + validKey.id + ')'
|
|
||||||
}),
|
|
||||||
message.getText()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const keyIds = arrayLength(signingKeyIds) ? signingKeyIds : null,
|
|
||||||
additional = keyIds
|
|
||||||
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(v => v).join(', ')
|
|
||||||
: '';
|
|
||||||
|
|
||||||
controlsHelper(
|
|
||||||
dom,
|
|
||||||
this,
|
|
||||||
false,
|
|
||||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : '')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
controlsHelper(dom, this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MailMessageView extends AbstractViewRight {
|
export class MailMessageView extends AbstractViewRight {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('MailMessageView');
|
super('MailMessageView');
|
||||||
|
|
@ -237,8 +178,7 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
pgpSigned: () => PgpUserStore.openpgp
|
pgpSigned: () => MessageUserStore.message() && !!MessageUserStore.message().pgpSigned(),
|
||||||
&& MessageUserStore.message() && !!MessageUserStore.message().pgpSigned(),
|
|
||||||
|
|
||||||
pgpEncrypted: () => PgpUserStore.openpgp
|
pgpEncrypted: () => PgpUserStore.openpgp
|
||||||
&& MessageUserStore.message() && MessageUserStore.message().isPgpEncrypted(),
|
&& MessageUserStore.message() && MessageUserStore.message().isPgpEncrypted(),
|
||||||
|
|
@ -682,13 +622,13 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pgpDecrypt(self/*, event*/) {
|
pgpDecrypt(self) {
|
||||||
const message = self.message();
|
const message = self.message();
|
||||||
message && pgpClickHelper(message.body, message.plain(), message.getEmails(['from', 'to', 'cc']));
|
message && message.pgpDecrypt();
|
||||||
}
|
}
|
||||||
|
|
||||||
pgpVerify(self/*, event*/) {
|
pgpVerify(self) {
|
||||||
const message = self.message();
|
const message = self.message();
|
||||||
message && pgpClickHelper(message.body, message.plain());
|
message && message.pgpVerify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,45 @@ use RainLoop\Exceptions\ClientException;
|
||||||
use RainLoop\Model\Account;
|
use RainLoop\Model\Account;
|
||||||
use RainLoop\Notifications;
|
use RainLoop\Notifications;
|
||||||
use MailSo\Imap\SequenceSet;
|
use MailSo\Imap\SequenceSet;
|
||||||
|
use MailSo\Imap\Enumerations\FetchType;
|
||||||
use MailSo\Imap\Enumerations\MessageFlag;
|
use MailSo\Imap\Enumerations\MessageFlag;
|
||||||
|
|
||||||
trait Messages
|
trait Messages
|
||||||
{
|
{
|
||||||
|
public function DoPgpVerify() : array
|
||||||
|
{
|
||||||
|
$sFolderName = $this->GetActionParam('Folder', '');
|
||||||
|
$iUid = (int) $this->GetActionParam('Uid', 0);
|
||||||
|
$sBodyPartId = $this->GetActionParam('BodyPartId', '');
|
||||||
|
$sSigPartId = $this->GetActionParam('SigPartId', '');
|
||||||
|
$sMicAlg = $this->GetActionParam('MicAlg', '');
|
||||||
|
|
||||||
|
$oAccount = $this->initMailClientConnection();
|
||||||
|
|
||||||
|
$oImapClient = $this->MailClient()->ImapClient();
|
||||||
|
$oImapClient->FolderExamine($sFolderName);
|
||||||
|
|
||||||
|
$aFetchResponse = $oImapClient->Fetch([
|
||||||
|
// An empty section specification refers to the entire message, including the header.
|
||||||
|
// But Dovecot does not return it with BODY.PEEK[1], so we also use BODY.PEEK[1.MIME].
|
||||||
|
$aFetchItems[] = FetchType::BODY_PEEK.'['.$sBodyPartId.'.MIME]',
|
||||||
|
$aFetchItems[] = FetchType::BODY_PEEK.'['.$sBodyPartId.']',
|
||||||
|
$aFetchItems[] = FetchType::BODY_PEEK.'['.$sSigPartId.']'
|
||||||
|
], $iUid, true);
|
||||||
|
|
||||||
|
$oFetchResponse = $aFetchResponse[0];
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'MIME' => \trim($oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.'.MIME]')),
|
||||||
|
'Body' => \trim($oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.']')),
|
||||||
|
'Signature' => \trim($oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sSigPartId.']'))
|
||||||
|
];
|
||||||
|
|
||||||
|
// TODO: check gnugp and \SnappyMail\PGP\Keyservers::get() and \SnappyMail\PGP\Keyservers::index()
|
||||||
|
|
||||||
|
return $this->DefaultResponse(__FUNCTION__, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \MailSo\Base\Exceptions\Exception
|
* @throws \MailSo\Base\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue