X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fenotify.php;h=478b034e5f5bdb8b353b5eb1cd46a80b94a7daae;hb=725296a6f2189a5470eaab8bcdcc2645545de261;hp=e8e13574497d41f06fa39433422204c5a7051dd9;hpb=40a93223ee0fcc77d541f2ef9c3c02a2722a41fe;p=friendica.git diff --git a/include/enotify.php b/include/enotify.php index e8e1357449..478b034e5f 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -87,12 +87,15 @@ function notification($params) } $nickname = $user["nickname"]; + // Creates a new email builder for the notification email + $emailBuilder = DI::emailer()->newNotifyMail(); + // with $params['show_in_notification_page'] == false, the notification isn't inserted into // the database, and an email is sent if applicable. // default, if not specified: true $show_in_notification_page = isset($params['show_in_notification_page']) ? $params['show_in_notification_page'] : true; - $additional_mail_header = "X-Friendica-Account: <".$nickname."@".$hostname.">\n"; + $emailBuilder->setHeader('X-Friendica-Account', '<' . $nickname . '@' . $hostname . '>'); if (array_key_exists('item', $params)) { $title = $params['item']['title']; @@ -509,7 +512,8 @@ function notification($params) Logger::log('sending notification email'); if (isset($params['parent']) && (intval($params['parent']) != 0)) { - $id_for_parent = $params['parent'] . "@" . $hostname; + $parent = Item::selectFirst(['guid'], ['id' => $params['parent']]); + $message_id = "<" . $parent['guid'] . "@" . gethostname() . ">"; // Is this the first email notification for this parent item and user? if (!DBA::exists('notify-threads', ['master-parent-item' => $params['parent'], 'receiver-uid' => $params['uid']])) { @@ -520,13 +524,14 @@ function notification($params) 'receiver-uid' => $params['uid'], 'parent-item' => 0]; DBA::insert('notify-threads', $fields); - $additional_mail_header .= "Message-ID: <${id_for_parent}>\n"; + $emailBuilder->setHeader('Message-ID', $message_id); $log_msg = "include/enotify: No previous notification found for this parent:\n" . " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n"; Logger::log($log_msg, Logger::DEBUG); } else { // If not, just "follow" the thread. - $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n"; + $emailBuilder->setHeader('References', $message_id); + $emailBuilder->setHeader('In-Reply-To', $message_id); Logger::log("There's already a notification for this parent.", Logger::DEBUG); } } @@ -545,7 +550,6 @@ function notification($params) 'title' => $title, 'body' => $body, 'subject' => $subject, - 'headers' => $additional_mail_header, ]; Hook::callAll('enotify_mail', $datarray); @@ -564,13 +568,13 @@ function notification($params) // If a photo is present, add it to the email if (!empty($datarray['source_photo'])) { - $builder->withPhoto( + $emailBuilder->withPhoto( $datarray['source_photo'], $datarray['source_link'] ?? $sitelink, $datarray['source_name'] ?? $sitename); } - $email = $builder->build(); + $email = $emailBuilder->build(); // use the Emailer class to send the message return DI::emailer()->send($email);