]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Item.php
Merge pull request #11913 from tobiasd/2022.09-CHANGELOG
[friendica.git] / src / Content / Item.php
index d5c33a762c6f6955bc3591d6707f8db629729eb9..6cbcb636955f58446e6273e703a946995c6b0147 100644 (file)
@@ -22,7 +22,7 @@
 namespace Friendica\Content;
 
 use Friendica\Content\Text\BBCode;
-use Friendica\Content\Text\Markdown;
+use Friendica\Content\Text\HTML;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
@@ -656,9 +656,12 @@ class Item
         */
        public function createSharedBlockByArray(array $item): string
        {
-               if (!in_array($item['network'] ?? '', Protocol::FEDERATED)) {
+               if ($item['network'] == Protocol::FEED) {
+                       return PageInfo::getFooterFromUrl($item['plink']);
+               } elseif (!in_array($item['network'] ?? '', Protocol::FEDERATED)) {
                        $item['guid'] = '';
                        $item['uri']  = '';
+                       $item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
                }
 
                $shared_content = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid'], $item['uri']);
@@ -667,10 +670,15 @@ class Item
                        $shared_content .= '[h3]' . $item['title'] . "[/h3]\n";
                }
 
+               $shared = BBCode::fetchShareAttributes($item['body']);
+
                // If it is a reshared post then reformat it to avoid display problems with two share elements
                if (Diaspora::isReshare($item['body'], false)) {
-                       $item['body'] = Markdown::toBBCode(BBCode::toMarkdown($item['body']));
-                       $item['body'] = Diaspora::replacePeopleGuid($item['body'], $item['author-link']);
+                       if (!empty($shared['guid']) && ($encaspulated_share = self::createSharedPostByGuid($shared['guid']))) {
+                               $item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encaspulated_share, $item['body']);
+                       }
+
+                       $item['body'] = HTML::toBBCode(BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::ACTIVITYPUB));
                }
 
                $shared_content .= $item['body'] . '[/share]';