]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Emailer.php
Don't create notifications for own posts
[friendica.git] / src / Util / Emailer.php
index 6a19e8e4587c929b80c0cf1895f187ad5383f033..d7ca234a98da82d7287f344f9bfd4929ba61044d 100644 (file)
@@ -32,10 +32,16 @@ class Emailer
         * @return bool
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function send($params)
+       public static function send(array $params)
        {
+               $params['sent'] = false;
+
                Hook::callAll('emailer_send_prepare', $params);
 
+               if ($params['sent']) {
+                       return true;
+               }
+
                $email_textonly = false;
                if (!empty($params['uid'])) {
                        $email_textonly = PConfig::get($params['uid'], "system", "email_textonly");
@@ -51,7 +57,7 @@ class Emailer
                                .rand(10000, 99999);
 
                // generate a multipart/alternative message header
-               $messageHeader = defaults($params, 'additionalMailHeader', '') .
+               $messageHeader = ($params['additionalMailHeader'] ?? '') .
                                                "From: $fromName <{$params['fromEmail']}>\n" .
                                                "Reply-To: $fromName <{$params['replyTo']}>\n" .
                                                "MIME-Version: 1.0\n" .
@@ -87,11 +93,16 @@ class Emailer
                        'subject' => $messageSubject,
                        'body' => $multipartMessageBody,
                        'headers' => $messageHeader,
-                       'parameters' => $sendmail_params
+                       'parameters' => $sendmail_params,
+                       'sent' => false,
                ];
 
                Hook::callAll("emailer_send", $hookdata);
 
+               if ($hookdata['sent']) {
+                       return true;
+               }
+
                $res = mail(
                        $hookdata['to'],
                        $hookdata['subject'],