diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index d111437dff..55a46b88aa 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -913,13 +913,18 @@ class BBCode
default:
$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;
+ if (!empty($contact)) {
+ $profile = Contact::getProfileLink($contact);
+ } else {
+ $profile = $attributes['profile'];
+ }
$gsid = ContactSelector::getServerIdForProfile($attributes['profile']);
$tpl = Renderer::getMarkupTemplate('shared_content.tpl');
$text .= self::SHARED_ANCHOR . Renderer::replaceMacros($tpl, [
- '$profile' => $attributes['profile'],
+ '$profile' => $profile,
'$avatar' => $attributes['avatar'],
'$author' => $attributes['author'],
'$link' => $attributes['link'],
@@ -1984,12 +1989,25 @@ class BBCode
'$1$3',
$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(
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
'$1$3',
$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], '' . $match[1] . '' . $match[3] . '', $text);
+ }
+
+ }
} elseif ($simple_html == self::MASTODON_API) {
$text = preg_replace(
"/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
diff --git a/src/Protocol/ATProtocol/Processor.php b/src/Protocol/ATProtocol/Processor.php
index 2c0e2528c5..1ac2a9f00c 100755
--- a/src/Protocol/ATProtocol/Processor.php
+++ b/src/Protocol/ATProtocol/Processor.php
@@ -506,13 +506,10 @@ class Processor
break;
case 'app.bsky.richtext.facet#mention':
- $contact = Contact::getByURL($feature->did, null, ['id']);
- if (!empty($contact['id'])) {
- $url = $this->baseURL . '/contact/' . $contact['id'];
- if (substr($linktext, 0, 1) == '@') {
- $prefix .= '@';
- $linktext = substr($linktext, 1);
- }
+ $url = $feature->did;
+ if (substr($linktext, 0, 1) == '@') {
+ $prefix .= '@';
+ $linktext = substr($linktext, 1);
}
break;