mirror of
https://github.com/friendica/friendica
synced 2025-05-20 00:24:12 +02:00
Use alias for profile link in reshare
This commit is contained in:
parent
f49172e9c0
commit
3af5caa950
2 changed files with 25 additions and 10 deletions
|
@ -913,13 +913,18 @@ class BBCode
|
||||||
default:
|
default:
|
||||||
$text = ($is_quote_share ? "\n" : '');
|
$text = ($is_quote_share ? "\n" : '');
|
||||||
|
|
||||||
$contact = Contact::getByURL($attributes['profile'], false, ['network']);
|
$contact = Contact::getByURL($attributes['profile'], false, ['network', 'url', 'alias']);
|
||||||
$network = $contact['network'] ?? Protocol::PHANTOM;
|
$network = $contact['network'] ?? Protocol::PHANTOM;
|
||||||
|
if (!empty($contact)) {
|
||||||
|
$profile = Contact::getProfileLink($contact);
|
||||||
|
} else {
|
||||||
|
$profile = $attributes['profile'];
|
||||||
|
}
|
||||||
|
|
||||||
$gsid = ContactSelector::getServerIdForProfile($attributes['profile']);
|
$gsid = ContactSelector::getServerIdForProfile($attributes['profile']);
|
||||||
$tpl = Renderer::getMarkupTemplate('shared_content.tpl');
|
$tpl = Renderer::getMarkupTemplate('shared_content.tpl');
|
||||||
$text .= self::SHARED_ANCHOR . Renderer::replaceMacros($tpl, [
|
$text .= self::SHARED_ANCHOR . Renderer::replaceMacros($tpl, [
|
||||||
'$profile' => $attributes['profile'],
|
'$profile' => $profile,
|
||||||
'$avatar' => $attributes['avatar'],
|
'$avatar' => $attributes['avatar'],
|
||||||
'$author' => $attributes['author'],
|
'$author' => $attributes['author'],
|
||||||
'$link' => $attributes['link'],
|
'$link' => $attributes['link'],
|
||||||
|
@ -1984,12 +1989,25 @@ class BBCode
|
||||||
'<a href="$2" class="mention hashtag" rel="tag">$1<span>$3</span></a>',
|
'<a href="$2" class="mention hashtag" rel="tag">$1<span>$3</span></a>',
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
} elseif (in_array($simple_html, [self::INTERNAL, self::EXTERNAL, self::TWITTER_API])) {
|
} elseif (in_array($simple_html, [self::EXTERNAL, self::TWITTER_API])) {
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
'<bdi>$1<a href="$2" class="userinfo mention" title="$3">$3</a></bdi>',
|
'<bdi>$1<a href="$2" class="userinfo mention" title="$3">$3</a></bdi>',
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
} elseif ($simple_html == self::INTERNAL) {
|
||||||
|
if (preg_match_all("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", $text, $matches, PREG_SET_ORDER)) {
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
$contact = Contact::getByURL($match[2], false, ['network', 'url', 'alias']);
|
||||||
|
if (!empty($contact)) {
|
||||||
|
$url = Contact::getProfileLink($contact);
|
||||||
|
} else {
|
||||||
|
$url = $match[2];
|
||||||
|
}
|
||||||
|
$text = str_replace($match[0], '<bdi>' . $match[1] . '<a href="' . $url . '" class="userinfo mention" title="' . $match[3] . '">' . $match[3] . '</a></bdi>', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} elseif ($simple_html == self::MASTODON_API) {
|
} elseif ($simple_html == self::MASTODON_API) {
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
|
|
|
@ -506,14 +506,11 @@ class Processor
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'app.bsky.richtext.facet#mention':
|
case 'app.bsky.richtext.facet#mention':
|
||||||
$contact = Contact::getByURL($feature->did, null, ['id']);
|
$url = $feature->did;
|
||||||
if (!empty($contact['id'])) {
|
|
||||||
$url = $this->baseURL . '/contact/' . $contact['id'];
|
|
||||||
if (substr($linktext, 0, 1) == '@') {
|
if (substr($linktext, 0, 1) == '@') {
|
||||||
$prefix .= '@';
|
$prefix .= '@';
|
||||||
$linktext = substr($linktext, 1);
|
$linktext = substr($linktext, 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'app.bsky.richtext.facet#tag':
|
case 'app.bsky.richtext.facet#tag':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue