]> git.mxchange.org Git - friendica.git/commitdiff
Preview of attached links work again
authorMichael <heluecht@pirati.ca>
Wed, 4 Jan 2023 21:52:02 +0000 (21:52 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 4 Jan 2023 21:52:02 +0000 (21:52 +0000)
src/Content/Item.php
src/Model/Item.php

index c4af86e6b1dc2eee3f8a6a2321f44789bb04093b..968509deed8afbce8e6bdfc86ce5cc8f4b1fe353 100644 (file)
@@ -948,15 +948,15 @@ class Item
 
        public function initializePost(array $post): array
        {
-               $post['wall']       = true;
-               $post['origin']     = true;
-               $post['network']    = Protocol::DFRN;
-               $post['protocol']   = Conversation::PARCEL_DIRECT;
-               $post['direction']  = Conversation::PUSH;
-               $post['guid']       = System::createUUID();
-               $post['uri']        = ItemModel::newURI($post['guid']);
-               $post['verb']       = Activity::POST;
-               $post['received']   = DateTimeFormat::utcNow();
+               $post['network']   = Protocol::DFRN;
+               $post['protocol']  = Conversation::PARCEL_DIRECT;
+               $post['direction'] = Conversation::PUSH;
+               $post['received']  = DateTimeFormat::utcNow();
+               $post['origin']    = true;
+               $post['wall']      = $post['wall'] ?? true;
+               $post['guid']      = $post['guid'] ?? System::createUUID();
+               $post['uri']       = $post['uri']  ?? ItemModel::newURI($post['guid']);
+               $post['verb']      = $post['verb'] ?? Activity::POST;
                $owner = User::getOwnerDataById($post['uid']);
 
                if (empty($post['contact-id'])) {
index f4bcb56e091d90382ed7d278ec97c4c74c9d5a5f..1eaa7cff2313d32a031319fb1834269880abe600 100644 (file)
@@ -2984,13 +2984,15 @@ class Item
                $item['hashtags'] = $tags['hashtags'];
                $item['mentions'] = $tags['mentions'];
 
-               $item['body'] = preg_replace("#\s*\[attachment .*?].*?\[/attachment]\s*#ism", "\n", $item['body']);
-
                if (!$is_preview) {
+                       $item['body'] = preg_replace("#\s*\[attachment .*?].*?\[/attachment]\s*#ism", "\n", $item['body']);
                        $item['body'] = Post\Media::removeFromEndOfBody($item['body'] ?? '');
                }
 
                $body = $item['body'];
+               if ($is_preview) {
+                       $item['body'] = preg_replace("#\s*\[attachment .*?].*?\[/attachment]\s*#ism", "\n", $item['body']);
+               }
 
                $fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media', 'quote-uri-id', 'post-type'];