X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fenotify.php;h=cfc03626f585459fa4d121f4bb4a3144fe333537;hb=fd73b0e1d2866701ed48d432ebcc0b32ee10a09f;hp=8936cadbe4c3eb666cff303420c2593f3d50facf;hpb=df24c0daebc01866eebf2efeeba97cda414cd71e;p=friendica.git diff --git a/include/enotify.php b/include/enotify.php index 8936cadbe4..cfc03626f5 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -1,6 +1,6 @@ t('%1$s replied to you on %2$s\'s %3$s %4$s'); - } elseif ($params['activity']['explicit_tagged']) { + } elseif (!empty($params['activity']['explicit_tagged'])) { $message = $l10n->t('%1$s tagged you on %2$s\'s %3$s %4$s'); } else { $message = $l10n->t('%1$s commented on %2$s\'s %3$s %4$s'); @@ -197,10 +197,10 @@ function notification($params) // Then look for the special cases // "your post" - if ($params['activity']['origin_thread']) { - if ($params['activity']['origin_comment']) { + if (!empty($params['activity']['origin_thread'])) { + if (!empty($params['activity']['origin_comment'])) { $message = $l10n->t('%1$s replied to you on your %2$s %3$s'); - } elseif ($params['activity']['explicit_tagged']) { + } elseif (!empty($params['activity']['explicit_tagged'])) { $message = $l10n->t('%1$s tagged you on your %2$s %3$s'); } else { $message = $l10n->t('%1$s commented on your %2$s %3$s'); @@ -209,9 +209,9 @@ function notification($params) $dest_str = sprintf($message, $params['source_name'], $item_post_type, $title); // "their post" } elseif ($item['author-link'] == $params['source_link']) { - if ($params['activity']['origin_comment']) { + if (!empty($params['activity']['origin_comment'])) { $message = $l10n->t('%1$s replied to you on their %2$s %3$s'); - } elseif ($params['activity']['explicit_tagged']) { + } elseif (!empty($params['activity']['explicit_tagged'])) { $message = $l10n->t('%1$s tagged you on their %2$s %3$s'); } else { $message = $l10n->t('%1$s commented on their %2$s %3$s'); @@ -224,7 +224,7 @@ function notification($params) // So, we cannot have different subjects for notifications of the same thread. // Before this we have the name of the replier on the subject rendering // different subjects for messages on the same thread. - if ($params['activity']['explicit_tagged']) { + if (!empty($params['activity']['explicit_tagged'])) { $subject = $l10n->t('%s %s tagged you', $subjectPrefix, $params['source_name']); $preamble = $l10n->t('%1$s tagged you at %2$s', $params['source_name'], $sitename); @@ -273,7 +273,7 @@ function notification($params) $epreamble = $l10n->t('%1$s [url=%2$s]shared a post[/url] from %3$s.', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]', $params['link'], '[url='.$params['origin_link'].']'.$params['origin_name'].'[/url]' - ); + ); } $sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.'); @@ -474,7 +474,7 @@ function notification($params) if ($show_in_notification_page) { $fields = [ 'name' => $params['source_name'] ?? '', - 'name_cache' => substr(strip_tags(BBCode::convert($params['source_name'])), 0, 255), + 'name_cache' => substr(strip_tags(BBCode::convertForUriId($uri_id, $params['source_name'])), 0, 255), 'url' => $params['source_link'] ?? '', 'photo' => $params['source_photo'] ?? '', 'link' => $itemlink ?? '', @@ -521,11 +521,10 @@ function notification($params) $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']])) { + if (!DBA::exists('notify-threads', ['master-parent-uri-id' => $parent_uri_id, 'receiver-uid' => $params['uid']])) { Logger::log("notify_id:" . intval($notify_id) . ", parent: " . intval($params['parent']) . "uid: " . intval($params['uid']), Logger::DEBUG); - $fields = ['notify-id' => $notify_id, 'master-parent-item' => $params['parent'], - 'master-parent-uri-id' => $parent_uri_id, + $fields = ['notify-id' => $notify_id, 'master-parent-uri-id' => $parent_uri_id, 'receiver-uid' => $params['uid'], 'parent-item' => 0]; DBA::insert('notify-threads', $fields); @@ -605,7 +604,7 @@ function check_user_notification(int $uri_id, int $uid) { $usernotifications = DBA::select('post-user-notification', ['uri-id', 'uid', 'notification-type'], $condition); while ($usernotification = DBA::fetch($usernotifications)) { - check_item_notification($usernotification['uri-id'], $usernotification['uid'], $usernotification['notification-type']); + check_item_notification($usernotification['uri-id'], $usernotification['uid'], $usernotification['notification-type'], $uid); } DBA::close($usernotifications); } @@ -619,11 +618,11 @@ function check_user_notification(int $uri_id, int $uid) { * @return bool * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ -function check_item_notification(int $uri_id, int $uid, int $notification_type) { +function check_item_notification(int $uri_id, int $uid, int $notification_type, $post_uid) { $fields = ['id', 'uri-id', 'mention', 'parent', 'parent-uri-id', 'thr-parent-id', 'title', 'body', 'author-link', 'author-name', 'author-avatar', 'author-id', 'gravity', 'guid', 'parent-uri', 'uri', 'contact-id', 'network']; - $condition = ['uri-id' => $uri_id, 'uid' => $uid, 'deleted' => false]; + $condition = ['uri-id' => $uri_id, 'uid' => [$uid, $post_uid], 'deleted' => false]; $item = Post::selectFirstForUser($uid, $fields, $condition); if (!DBA::isResult($item)) { return false;