Some Renames:
authornupplaPhil <admin@philipp.info>
Sun, 26 Jan 2020 22:47:16 +0000 (23:47 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 26 Jan 2020 22:47:16 +0000 (23:47 +0100)
- EMail => EMail
- toEmail => toAddress
- fromEmail => fromAddress

include/enotify.php
src/Object/EMail.php [deleted file]
src/Object/EMail/IEmail.php
src/Object/EMail/ItemCCEMail.php
src/Object/Email.php [new file with mode: 0644]
src/Util/Emailer.php

index f55c9f6..3332f4a 100644 (file)
@@ -15,10 +15,8 @@ use Friendica\Model\ItemContent;
 use Friendica\Model\Notify;
 use Friendica\Model\User;
 use Friendica\Model\UserItem;
-use Friendica\Object\EMail;
+use Friendica\Object\Email;
 use Friendica\Protocol\Activity;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Emailer;
 
 /**
  * Creates a notification entry and possibly sends a mail
@@ -610,7 +608,7 @@ function notification($params)
                        '$content_allowed' => $content_allowed,
                ]);
 
-               $email = new EMail($sender_name, $sender_email, $sender_email, $params['to_email'],
+               $email = new Email($sender_name, $sender_email, $sender_email, $params['to_email'],
                        $datarray['subject'], $email_html_body, $email_text_body,
                        $datarray['headers'], $params['uid']);
 
diff --git a/src/Object/EMail.php b/src/Object/EMail.php
deleted file mode 100644 (file)
index 5f15273..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-namespace Friendica\Object;
-
-use Friendica\Object\EMail\IEmail;
-
-/**
- * The default implementation of the IEmail interface
- *
- * Provides the possibility to reuse the email instance with new recipients (@see EMail::withRecipient())
- */
-class EMail implements IEmail
-{
-       /** @var string */
-       private $fromName;
-       /** @var string */
-       private $fromEmail;
-       /** @var string */
-       private $replyTo;
-
-       /** @var string */
-       private $toEmail;
-
-       /** @var string */
-       private $subject;
-       /** @var string */
-       private $msgHtml;
-       /** @var string */
-       private $msgText;
-
-       /** @var string */
-       private $additionalMailHeader = '';
-       /** @var int|null */
-       private $toUid = null;
-
-       public function __construct(string $fromName, string $fromEmail, string $replyTo, string $toEmail,
-                                   string $subject, string $msgHtml, string $msgText,
-                                   string $additionalMailHeader = '', int $toUid = null)
-       {
-               $this->fromName             = $fromName;
-               $this->fromEmail            = $fromEmail;
-               $this->replyTo              = $replyTo;
-               $this->toEmail              = $toEmail;
-               $this->subject              = $subject;
-               $this->msgHtml              = $msgHtml;
-               $this->msgText              = $msgText;
-               $this->additionalMailHeader = $additionalMailHeader;
-               $this->toUid                = $toUid;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getFromName()
-       {
-               return $this->fromName;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getFromEmail()
-       {
-               return $this->fromEmail;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getReplyTo()
-       {
-               return $this->replyTo;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getToEmail()
-       {
-               return $this->toEmail;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getSubject()
-       {
-               return $this->subject;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getMessage(bool $plain = false)
-       {
-               if ($plain) {
-                       return $this->msgText;
-               } else {
-                       return $this->msgHtml;
-               }
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getAdditionalMailHeader()
-       {
-               return $this->additionalMailHeader;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public function getRecipientUid()
-       {
-               return $this->toUid;
-       }
-
-       /**
-        * Returns the current email with a new recipient
-        *
-        * @param string $email The email of the recipient
-        * @param int    $uid   The (optional) UID of the recipient for further infos
-        *
-        * @return static
-        */
-       public function withRecipient(string $email, int $uid = null)
-       {
-               $newEmail          = clone $this;
-               $newEmail->toEmail = $email;
-               $newEmail->toUid   = $uid;
-
-               return $newEmail;
-       }
-}
index 24df41b..6a159c0 100644 (file)
@@ -23,7 +23,7 @@ interface IEmail
         *
         * @return string
         */
-       function getFromEmail();
+       function getFromAddress();
 
        /**
         * Gets the UID of the sender of this email
@@ -44,7 +44,7 @@ interface IEmail
         *
         * @return string
         */
-       function getToEmail();
+       function getToAddress();
 
        /**
         * Gets the subject of this email
index c896360..6ea1ae8 100644 (file)
@@ -7,12 +7,12 @@ use Friendica\App\BaseURL;
 use Friendica\Content\Text\HTML;
 use Friendica\Core\L10n;
 use Friendica\Model\Item;
-use Friendica\Object\EMail;
+use Friendica\Object\Email;
 
 /**
  * Class for creating CC emails based on a received item
  */
-class ItemCCEMail extends EMail
+class ItemCCEMail extends Email
 {
        public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toEmail, string $authorThumb)
        {
@@ -21,7 +21,7 @@ class ItemCCEMail extends EMail
                $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->user['nickname']) . EOL;
                $disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
                if (!$item['title'] == '') {
-                       $subject = EMail::encodeHeader($item['title'], 'UTF-8');
+                       $subject = Email::encodeHeader($item['title'], 'UTF-8');
                } else {
                        $subject = Email::encodeHeader('[Friendica]' . ' ' . $l10n->t('%s posted an update.', $a->user['username']), 'UTF-8');
                }
diff --git a/src/Object/Email.php b/src/Object/Email.php
new file mode 100644 (file)
index 0000000..7a6858b
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+
+namespace Friendica\Object;
+
+use Friendica\Object\EMail\IEmail;
+
+/**
+ * The default implementation of the IEmail interface
+ *
+ * Provides the possibility to reuse the email instance with new recipients (@see Email::withRecipient())
+ */
+class Email implements IEmail
+{
+       /** @var string */
+       private $fromName;
+       /** @var string */
+       private $fromAddress;
+       /** @var string */
+       private $replyTo;
+
+       /** @var string */
+       private $toAddress;
+
+       /** @var string */
+       private $subject;
+       /** @var string */
+       private $msgHtml;
+       /** @var string */
+       private $msgText;
+
+       /** @var string */
+       private $additionalMailHeader = '';
+       /** @var int|null */
+       private $toUid = null;
+
+       public function __construct(string $fromName, string $fromEmail, string $replyTo, string $toEmail,
+                                   string $subject, string $msgHtml, string $msgText,
+                                   string $additionalMailHeader = '', int $toUid = null)
+       {
+               $this->fromName             = $fromName;
+               $this->fromAddress          = $fromEmail;
+               $this->replyTo              = $replyTo;
+               $this->toAddress            = $toEmail;
+               $this->subject              = $subject;
+               $this->msgHtml              = $msgHtml;
+               $this->msgText              = $msgText;
+               $this->additionalMailHeader = $additionalMailHeader;
+               $this->toUid                = $toUid;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getFromName()
+       {
+               return $this->fromName;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getFromAddress()
+       {
+               return $this->fromAddress;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getReplyTo()
+       {
+               return $this->replyTo;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getToAddress()
+       {
+               return $this->toAddress;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getSubject()
+       {
+               return $this->subject;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getMessage(bool $plain = false)
+       {
+               if ($plain) {
+                       return $this->msgText;
+               } else {
+                       return $this->msgHtml;
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getAdditionalMailHeader()
+       {
+               return $this->additionalMailHeader;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public function getRecipientUid()
+       {
+               return $this->toUid;
+       }
+
+       /**
+        * Returns the current email with a new recipient
+        *
+        * @param string $email The email of the recipient
+        * @param int    $uid   The (optional) UID of the recipient for further infos
+        *
+        * @return static
+        */
+       public function withRecipient(string $email, int $uid = null)
+       {
+               $newEmail            = clone $this;
+               $newEmail->toAddress = $email;
+               $newEmail->toUid     = $uid;
+
+               return $newEmail;
+       }
+}
index f2f1ede..b8dc127 100644 (file)
@@ -59,7 +59,7 @@ class Emailer
                }
 
                $fromName       = Email::encodeHeader(html_entity_decode($email->getFromName(), ENT_QUOTES, 'UTF-8'), 'UTF-8');
-               $fromEmail      = $email->getFromEmail();
+               $fromEmail      = $email->getFromAddress();
                $replyTo        = $email->getReplyTo();
                $messageSubject = Email::encodeHeader(html_entity_decode($email->getSubject(), ENT_QUOTES, 'UTF-8'), 'UTF-8');
 
@@ -102,7 +102,7 @@ class Emailer
 
                // send the message
                $hookdata = [
-                       'to'         => $email->getToEmail(),
+                       'to'         => $email->getToAddress(),
                        'subject'    => $messageSubject,
                        'body'       => $multipartMessageBody,
                        'headers'    => $messageHeader,
@@ -123,7 +123,7 @@ class Emailer
                        $hookdata['headers'],
                        $hookdata['parameters']
                );
-               $this->logger->debug('header ' . 'To: ' . $email->getToEmail() . '\n' . $messageHeader);
+               $this->logger->debug('header ' . 'To: ' . $email->getToAddress() . '\n' . $messageHeader);
                $this->logger->debug('return value ' . (($res) ? 'true' : 'false'));
                return $res;
        }