]> git.mxchange.org Git - friendica-addons.git/commitdiff
Fix secure Mail addon
authornupplaPhil <admin@philipp.info>
Fri, 31 Jan 2020 18:32:16 +0000 (19:32 +0100)
committernupplaPhil <admin@philipp.info>
Fri, 31 Jan 2020 18:32:16 +0000 (19:32 +0100)
securemail/securemail.php

index 1ec1aa7b809165279299ffd669a46aba1029416d..b45a91bcc0b82259ca38507b0bffcdec5f0d7085 100644 (file)
@@ -116,6 +116,8 @@ function securemail_settings_post(App &$a, array &$b)
  */
 function securemail_emailer_send_prepare(App &$a, IEmail &$email)
 {
+       DI::logger()->warning('start securemail', ['email' => $email]);
+
        if (empty($email->getRecipientUid())) {
                return;
        }
@@ -124,6 +126,7 @@ function securemail_emailer_send_prepare(App &$a, IEmail &$email)
 
        $enable_checked = DI::pConfig()->get($uid, 'securemail', 'enable');
        if (!$enable_checked) {
+               DI::logger()->warning('No check!!', ['email' => $email]);
                return;
        }
 
@@ -133,12 +136,17 @@ function securemail_emailer_send_prepare(App &$a, IEmail &$email)
        $marker = empty($matches[1]) ? 'MESSAGE' : $matches[1];
        $public_key = OpenPGP::unarmor($public_key_ascii, $marker);
 
+       DI::logger()->warning('public key', ['public_key' => $public_key]);
+
        $key = OpenPGP_Message::parse($public_key);
 
        $data = new OpenPGP_LiteralDataPacket($email->getMessage(true), [
                'format' => 'u',
                'filename' => 'encrypted.gpg'
        ]);
+
+       DI::logger()->warning('data', ['data' => $data]);
+
        try {
                $encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message([$data]));
                $armored_encrypted = wordwrap(
@@ -148,10 +156,10 @@ function securemail_emailer_send_prepare(App &$a, IEmail &$email)
                        true
                );
 
-               $email = Friendica\Object\EMail::createFromPrototype($email, [
-                       'textVersion' => $armored_encrypted,
-                       'htmlVersion' => null,
-               ]);
+               $email = $email->withMessage($armored_encrypted, null);
+
+               DI::logger()->warning('End securemail', ['email' => $email]);
+
        } catch (Exception $e) {
                DI::logger()->warning('Encryption failed.', ['email' => $email, 'exception' => $e]);
        }