Display the contact alias if the URL is no HTTP link

This commit is contained in:
Michael 2023-06-18 16:49:38 +00:00
parent 6d911a8f39
commit 4c3f2441f7
16 changed files with 528 additions and 303 deletions

View file

@ -29,6 +29,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Util\Network;
use Friendica\Util\Strings;
/**
@ -50,9 +51,15 @@ class VCard
Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
}
if (!Network::isValidHttpUrl($contact['url']) && Network::isValidHttpUrl($contact['alias'])) {
$url = $contact['alias'];
} else {
$url = $contact['url'];
}
if ($contact['network'] != '') {
$network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
$network_avatar = ContactSelector::networkToIcon($contact['network'], $contact['url']);
$network_link = Strings::formatNetworkName($contact['network'], $url);
$network_avatar = ContactSelector::networkToIcon($contact['network'], $url);
} else {
$network_link = '';
$network_avatar = '';
@ -83,9 +90,9 @@ class VCard
if (empty($contact['self']) && Protocol::supportsFollow($contact['network'])) {
if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
$unfollow_link = 'contact/unfollow?url=' . urlencode($url) . '&auto=1';
} elseif (!$pending) {
$follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
$follow_link = 'contact/follow?url=' . urlencode($url) . '&auto=1';
}
}
@ -97,7 +104,7 @@ class VCard
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
'$contact' => $contact,
'$photo' => $photo,
'$url' => Contact::magicLinkByContact($contact, $contact['url']),
'$url' => Contact::magicLinkByContact($contact, $url),
'$about' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'] ?? ''),
'$xmpp' => DI::l10n()->t('XMPP:'),
'$matrix' => DI::l10n()->t('Matrix:'),