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

@ -3490,6 +3490,21 @@ class Contact
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
*
@ -3548,7 +3563,7 @@ class Contact
*/
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()) {
return $destination;