From: Michael Date: Sat, 3 Jun 2023 15:27:14 +0000 (+0000) Subject: Improved profile summary for notifications X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=921e070b2235436ca0947e3f27706cbd5cd9d0a1;p=friendica.git Improved profile summary for notifications --- diff --git a/src/Model/Post/UserNotification.php b/src/Model/Post/UserNotification.php index dd0bbbe1ec..012a49dbf5 100644 --- a/src/Model/Post/UserNotification.php +++ b/src/Model/Post/UserNotification.php @@ -133,7 +133,7 @@ class UserNotification public static function setNotification(int $uri_id, int $uid) { $fields = ['id', 'uri-id', 'parent-uri-id', 'uid', 'body', 'parent', 'gravity', 'vid', 'gravity', - 'contact-id', 'author-id', 'owner-id', 'causer-id', + 'contact-id', 'author-id', 'owner-id', 'causer-id', 'private', 'thr-parent', 'thr-parent-id', 'parent-uri-id', 'parent-uri', 'verb']; $item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]); if (!DBA::isResult($item)) { @@ -398,45 +398,23 @@ class UserNotification */ private static function getProfileForUser(int $uid): array { - $notification_data = ['uid' => $uid, 'profiles' => []]; - Hook::callAll('check_item_notification', $notification_data); - - $profiles = $notification_data['profiles']; - - $user = DBA::selectFirst('user', ['nickname'], ['uid' => $uid]); - if (!DBA::isResult($user)) { - return []; - } - - $owner = DBA::selectFirst('contact', ['url', 'alias'], ['self' => true, 'uid' => $uid]); + $owner = User::getOwnerDataById($uid); if (!DBA::isResult($owner)) { return []; } - // This is our regular URL format - $profiles[] = $owner['url']; + $profiles = [$owner['nurl']]; - // Now the alias - $profiles[] = $owner['alias']; - - // Notifications from Diaspora often have a URL in the Diaspora format - $profiles[] = DI::baseUrl() . '/u/' . $user['nickname']; + $notification_data = ['uid' => $uid, 'profiles' => []]; + Hook::callAll('check_item_notification', $notification_data); - // Validate and add profile links - foreach ($profiles as $key => $profile) { - // Check for invalid profile urls (without scheme, host or path) and remove them + // Normalize the connector profiles + foreach ($notification_data['profiles'] as $profile) { if (empty(parse_url($profile, PHP_URL_SCHEME)) || empty(parse_url($profile, PHP_URL_HOST)) || empty(parse_url($profile, PHP_URL_PATH))) { - unset($profiles[$key]); - continue; + $profiles[] = $profile; + } else { + $profiles[] = Strings::normaliseLink($profile); } - - // Add the normalized form - $profile = Strings::normaliseLink($profile); - $profiles[] = $profile; - - // Add the SSL form - $profile = str_replace('http://', 'https://', $profile); - $profiles[] = $profile; } return array_unique($profiles);