Issue 13828: Use the alias as profile link if present (#13829)

* Issue 13828: Use the alias as profile link if present

* Updated messages.po
This commit is contained in:
Michael Vogel 2024-01-14 10:08:00 +01:00 committed by GitHub
parent 5dc49352e8
commit 02123bda98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 22 deletions

View file

@ -383,7 +383,7 @@ class Item
'url' => $item['author-link'], 'url' => $item['author-link'],
'alias' => $item['author-alias'], 'alias' => $item['author-alias'],
]; ];
$profile_link = Contact::magicLinkByContact($author, $item['author-link']); $profile_link = Contact::magicLinkByContact($author, Contact::getProfileLink($author));
if (strpos($profile_link, 'contact/redir/') === 0) { if (strpos($profile_link, 'contact/redir/') === 0) {
$status_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']); $status_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']);
$photos_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']); $photos_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']);

View file

@ -45,19 +45,21 @@ class Hovercard
$actions = []; $actions = [];
} }
$contact_url = Contact::getProfileLink($contact);
// Move the contact data to the profile array so we can deliver it to // Move the contact data to the profile array so we can deliver it to
$tpl = Renderer::getMarkupTemplate('hovercard.tpl'); $tpl = Renderer::getMarkupTemplate('hovercard.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'$profile' => [ '$profile' => [
'name' => $contact['name'], 'name' => $contact['name'],
'nick' => $contact['nick'], 'nick' => $contact['nick'],
'addr' => $contact['addr'] ?: $contact['url'], 'addr' => $contact['addr'] ?: $contact_url,
'thumb' => Contact::getThumb($contact), 'thumb' => Contact::getThumb($contact),
'url' => Contact::magicLinkByContact($contact), 'url' => Contact::magicLinkByContact($contact),
'nurl' => $contact['nurl'], 'nurl' => $contact['nurl'],
'location' => $contact['location'], 'location' => $contact['location'],
'about' => $contact['about'], 'about' => $contact['about'],
'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']), 'network_link' => Strings::formatNetworkName($contact['network'], $contact_url),
'tags' => $contact['keywords'], 'tags' => $contact['keywords'],
'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'], 'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'],
'account_type' => Contact::getAccountType($contact['contact-type']), 'account_type' => Contact::getAccountType($contact['contact-type']),

View file

@ -50,11 +50,7 @@ class VCard
Logger::warning('Incomplete contact', ['contact' => $contact ?? []]); Logger::warning('Incomplete contact', ['contact' => $contact ?? []]);
} }
if (!Network::isValidHttpUrl($contact['url']) && Network::isValidHttpUrl($contact['alias'])) { $contact_url = Contact::getProfileLink($contact);
$contact_url = $contact['alias'];
} else {
$contact_url = $contact['url'];
}
if ($contact['network'] != '') { if ($contact['network'] != '') {
$network_link = Strings::formatNetworkName($contact['network'], $contact_url); $network_link = Strings::formatNetworkName($contact['network'], $contact_url);

View file

@ -3490,6 +3490,21 @@ class Contact
return array_column($contacts, 'id'); return array_column($contacts, 'id');
} }
/**
* Return the link to the profile
*
* @param array $contact
* @return string
*/
public static function getProfileLink(array $contact): string
{
if (!empty($contact['alias']) && Network::isValidHttpUrl($contact['alias']) && (($contact['network'] ?? '') != Protocol::DFRN)) {
return $contact['alias'];
} else {
return $contact['url'];
}
}
/** /**
* Returns a magic link to authenticate remote visitors * Returns a magic link to authenticate remote visitors
* *
@ -3548,7 +3563,7 @@ class Contact
*/ */
public static function magicLinkByContact(array $contact, string $url = ''): string public static function magicLinkByContact(array $contact, string $url = ''): string
{ {
$destination = $url ?: (!Network::isValidHttpUrl($contact['url']) && !empty($contact['alias']) && Network::isValidHttpUrl($contact['alias']) ? $contact['alias'] : $contact['url']); $destination = $url ?: self::getProfileLink($contact);
if (!DI::userSession()->isAuthenticated()) { if (!DI::userSession()->isAuthenticated()) {
return $destination; return $destination;

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2024.03-dev\n" "Project-Id-Version: 2024.03-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-03 19:19+0000\n" "POT-Creation-Date: 2024-01-14 07:50+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1377,7 +1377,7 @@ msgstr ""
msgid "Public post" msgid "Public post"
msgstr "" msgstr ""
#: src/Content/Conversation.php:426 src/Content/Widget/VCard.php:131 #: src/Content/Conversation.php:426 src/Content/Widget/VCard.php:127
#: src/Model/Profile.php:483 src/Module/Admin/Logs/View.php:92 #: src/Model/Profile.php:483 src/Module/Admin/Logs/View.php:92
#: src/Module/Post/Edit.php:181 #: src/Module/Post/Edit.php:181
msgid "Message" msgid "Message"
@ -2220,7 +2220,7 @@ msgstr ""
msgid "The end" msgid "The end"
msgstr "" msgstr ""
#: src/Content/Text/HTML.php:859 src/Content/Widget/VCard.php:127 #: src/Content/Text/HTML.php:859 src/Content/Widget/VCard.php:123
#: src/Model/Profile.php:477 src/Module/Contact/Profile.php:471 #: src/Model/Profile.php:477 src/Module/Contact/Profile.php:471
msgid "Follow" msgid "Follow"
msgstr "" msgstr ""
@ -2420,27 +2420,27 @@ msgstr[1] ""
msgid "More Trending Tags" msgid "More Trending Tags"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:106 src/Model/Contact.php:1204 #: src/Content/Widget/VCard.php:102 src/Model/Contact.php:1204
#: src/Model/Profile.php:461 #: src/Model/Profile.php:461
msgid "Post to group" msgid "Post to group"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:110 src/Model/Contact.php:1209 #: src/Content/Widget/VCard.php:106 src/Model/Contact.php:1209
#: src/Model/Profile.php:466 src/Module/Moderation/Item/Source.php:85 #: src/Model/Profile.php:466 src/Module/Moderation/Item/Source.php:85
msgid "Mention" msgid "Mention"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:120 src/Model/Profile.php:380 #: src/Content/Widget/VCard.php:116 src/Model/Profile.php:380
#: src/Module/Contact/Profile.php:408 src/Module/Profile/Profile.php:199 #: src/Module/Contact/Profile.php:408 src/Module/Profile/Profile.php:199
msgid "XMPP:" msgid "XMPP:"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:121 src/Model/Profile.php:381 #: src/Content/Widget/VCard.php:117 src/Model/Profile.php:381
#: src/Module/Contact/Profile.php:410 src/Module/Profile/Profile.php:203 #: src/Module/Contact/Profile.php:410 src/Module/Profile/Profile.php:203
msgid "Matrix:" msgid "Matrix:"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:122 src/Model/Event.php:82 #: src/Content/Widget/VCard.php:118 src/Model/Event.php:82
#: src/Model/Event.php:109 src/Model/Event.php:471 src/Model/Event.php:963 #: src/Model/Event.php:109 src/Model/Event.php:471 src/Model/Event.php:963
#: src/Model/Profile.php:375 src/Module/Contact/Profile.php:406 #: src/Model/Profile.php:375 src/Module/Contact/Profile.php:406
#: src/Module/Directory.php:147 src/Module/Notifications/Introductions.php:187 #: src/Module/Directory.php:147 src/Module/Notifications/Introductions.php:187
@ -2448,18 +2448,18 @@ msgstr ""
msgid "Location:" msgid "Location:"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:125 src/Model/Profile.php:490 #: src/Content/Widget/VCard.php:121 src/Model/Profile.php:490
#: src/Module/Notifications/Introductions.php:201 #: src/Module/Notifications/Introductions.php:201
msgid "Network:" msgid "Network:"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:129 src/Model/Contact.php:1237 #: src/Content/Widget/VCard.php:125 src/Model/Contact.php:1237
#: src/Model/Contact.php:1249 src/Model/Profile.php:479 #: src/Model/Contact.php:1249 src/Model/Profile.php:479
#: src/Module/Contact/Profile.php:463 #: src/Module/Contact/Profile.php:463
msgid "Unfollow" msgid "Unfollow"
msgstr "" msgstr ""
#: src/Content/Widget/VCard.php:135 src/Model/Contact.php:1206 #: src/Content/Widget/VCard.php:131 src/Model/Contact.php:1206
#: src/Model/Profile.php:463 #: src/Model/Profile.php:463
msgid "View group" msgid "View group"
msgstr "" msgstr ""