]> git.mxchange.org Git - friendica.git/commitdiff
split mailbuilder types
authornupplaPhil <admin+github@philipp.info>
Tue, 4 Feb 2020 20:27:52 +0000 (21:27 +0100)
committernupplaPhil <admin+github@philipp.info>
Tue, 4 Feb 2020 20:14:39 +0000 (21:14 +0100)
include/enotify.php
src/Util/EMailer/NotifyMailBuilder.php
src/Util/EMailer/SystemMailBuilder.php
src/Util/Emailer.php

index 9a3e2b06682ca2caaac49f49bff130fd591fa49f..9016249a5b0f27f68c859049e885fa0551659a97 100644 (file)
@@ -502,7 +502,7 @@ function notification($params)
                Hook::callAll('enotify_mail', $datarray);
 
                $builder = DI::emailer()
-                       ->newNotifyMail($l10n)
+                       ->newNotifyMail()
                        ->addHeaders($datarray['headers'])
                        ->withRecipient($params['to_email'])
                        ->forUser($datarray['uid'])
index ca2add0cac74d08cdd468b31a96043ebd66c24f5..d571e874225baff4cdbe11c3060ca573e40d5efb 100644 (file)
@@ -13,8 +13,18 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
 /**
  * Builder for notification emails (notification, source, links, ...)
  */
-class NotifyMailBuilder extends SystemMailBuilder
+class NotifyMailBuilder extends MailBuilder
 {
+       /** @var string */
+       protected $subject;
+       /** @var string */
+       protected $preamble;
+       /** @var string */
+       protected $body;
+
+       /** @var string */
+       protected $siteAdmin;
+
        /** @var bool */
        private $contentAllowed = true;
        /** @var string */
@@ -42,7 +52,16 @@ class NotifyMailBuilder extends SystemMailBuilder
 
        public function __construct(L10n $l10n, BaseURL $baseUrl, IConfig $config, string $siteEmailAddress, string $siteName)
        {
-               parent::__construct($l10n, $baseUrl, $config, $siteEmailAddress, $siteName);
+               parent::__construct($l10n, $baseUrl, $config);
+
+               if ($this->config->get('config', 'admin_name')) {
+                       $this->siteAdmin = $l10n->t('%1$s, %2$s Administrator', $this->config->get('config', 'admin_name'), $siteName);
+               } else {
+                       $this->siteAdmin = $l10n->t('%s Administrator', $siteName);
+               }
+
+               // Set the system wide site address/name as sender (default for system mails)
+               $this->withSender($siteName, $siteEmailAddress, $siteEmailAddress);
 
                // check whether sending post content in email notifications is allowed
                $this->contentAllowed = $this->config->get('system', 'enotify_no_content');
@@ -60,9 +79,16 @@ class NotifyMailBuilder extends SystemMailBuilder
         */
        public function withNotification(string $subject, string $preamble, string $title, string $body = null)
        {
+               if (!isset($body)) {
+                       $body = $preamble;
+               }
+
                $this->title = stripslashes($title);
+               $this->subject  = $subject;
+               $this->preamble = $preamble;
+               $this->body     = $body;
 
-               return $this->withMessage($subject, $preamble, $body);
+               return $this;
        }
 
        /**
index 24c1593c98dfbb43fd7b0195e785371ee32c6c41..7f8a22b9d5e2d7cb3ad57d20f7bf233e35016e33 100644 (file)
@@ -38,9 +38,7 @@ class SystemMailBuilder extends MailBuilder
                }
 
                // Set the system wide site address/name as sender (default for system mails)
-               $this->senderName    = $siteName;
-               $this->senderAddress = $siteEmailAddress;
-               $this->senderNoReply = $siteEmailAddress;
+               $this->withSender($siteName, $siteEmailAddress, $siteEmailAddress);
        }
 
        /**
index 1717b994a41a380f4f7c77cc4c77b6f817285ef5..0e459360146482e7fb90e21d661c7746d974fd42 100644 (file)
@@ -96,13 +96,11 @@ class Emailer
         *
         * @see Notify
         *
-        * @param L10n $l10n The chosen language for the new email
-        *
         * @return NotifyMailBuilder
         */
-       public function newNotifyMail(L10n $l10n)
+       public function newNotifyMail()
        {
-               return new NotifyMailBuilder($l10n, $this->baseUrl, $this->config,
+               return new NotifyMailBuilder($this->l10n, $this->baseUrl, $this->config,
                        $this->getSiteEmailAddress(), $this->getSiteEmailName());
        }