X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=securemail%2Fsecuremail.php;h=fb801a4ce84bc8f03e88aab4d7fe438908631f12;hb=2dbcc42384b85e5253b939f528236f41909b1596;hp=1ec1aa7b809165279299ffd669a46aba1029416d;hpb=360e58e6e3451d219ae94a051427a1d1713f454c;p=friendica-addons.git diff --git a/securemail/securemail.php b/securemail/securemail.php index 1ec1aa7b..fb801a4c 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -26,16 +26,6 @@ function securemail_install() Logger::log('installed securemail'); } -function securemail_uninstall() -{ - Hook::unregister('addon_settings', 'addon/securemail/securemail.php', 'securemail_settings'); - Hook::unregister('addon_settings_post', 'addon/securemail/securemail.php', 'securemail_settings_post'); - - Hook::unregister('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare'); - - Logger::log('removed securemail'); -} - /** * @brief Build user settings form * @@ -86,7 +76,6 @@ function securemail_settings_post(App &$a, array &$b) DI::pConfig()->set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); $enable = (!empty($_POST['securemail-enable']) ? 1 : 0); DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable); - info(DI::l10n()->t('Secure Mail Settings saved.') . EOL); if ($_POST['securemail-submit'] == DI::l10n()->t('Save and send test')) { @@ -124,6 +113,7 @@ function securemail_emailer_send_prepare(App &$a, IEmail &$email) $enable_checked = DI::pConfig()->get($uid, 'securemail', 'enable'); if (!$enable_checked) { + DI::logger()->debug('No securemail enabled.'); return; } @@ -139,6 +129,7 @@ function securemail_emailer_send_prepare(App &$a, IEmail &$email) 'format' => 'u', 'filename' => 'encrypted.gpg' ]); + try { $encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message([$data])); $armored_encrypted = wordwrap( @@ -148,10 +139,8 @@ 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); + } catch (Exception $e) { DI::logger()->warning('Encryption failed.', ['email' => $email, 'exception' => $e]); }