}
$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'];
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']])) {
'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);
}
}
'title' => $title,
'body' => $body,
'subject' => $subject,
- 'headers' => $additional_mail_header,
];
Hook::callAll('enotify_mail', $datarray);
// 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);
if ($item['gravity'] == GRAVITY_ACTIVITY) {
$parent_item = Item::selectFirst($fields, ['uri-id' => $item['thr-parent-id'], 'uid' => [$uid, 0]]);
if (DBA::isResult($parent_item)) {
+ // Don't notify on own entries
+ if (User::getIdForURL($parent_item['author-link']) == $uid) {
+ return false;
+ }
+
$params['origin_name'] = $parent_item['author-name'];
$params['origin_link'] = $parent_item['author-link'];
$params['origin_photo'] = $parent_item['author-avatar'];