From: Michael <heluecht@pirati.ca>
Date: Wed, 4 Jan 2023 21:52:02 +0000 (+0000)
Subject: Preview of attached links work again
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9a1a406c038e21ca1de124a7271372a977ea0d7e;p=friendica.git

Preview of attached links work again
---

diff --git a/src/Content/Item.php b/src/Content/Item.php
index c4af86e6b1..968509deed 100644
--- a/src/Content/Item.php
+++ b/src/Content/Item.php
@@ -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'])) {
diff --git a/src/Model/Item.php b/src/Model/Item.php
index f4bcb56e09..1eaa7cff23 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -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'];