From: Michael <heluecht@pirati.ca>
Date: Fri, 7 Oct 2022 05:51:36 +0000 (+0000)
Subject: Simplified share element
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d7a9745ffd2d20581a04bd70fcf1459a36c96377;p=friendica.git

Simplified share element
---

diff --git a/mod/share.php b/mod/share.php
index 09097f070f..792ee40082 100644
--- a/mod/share.php
+++ b/mod/share.php
@@ -44,7 +44,7 @@ function share_init(App $a) {
 		$pos = strpos($item['body'], "[share");
 		$o = substr($item['body'], $pos);
 	} else {
-		$o = "[share message_id='" . $item['uri'] . "'][/share]";
+		$o = "[share]" . $item['uri'] . "[/share]";
 	}
 
 	echo $o;
diff --git a/src/Model/Item.php b/src/Model/Item.php
index 6cce806bed..a88e61124a 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -3666,9 +3666,18 @@ class Item
 	 */
 	public static function improveSharedDataInBody(array $item): string
 	{
-		$shared = BBCode::fetchShareAttributes($item['body']);
-		if (empty($shared['link']) && empty($shared['message_id'])) {
-			return $item['body'];
+		if (preg_match('#\[share](.*)\[/share]#', $item['body'], $matches)) {
+			$shared = [
+				'message_id' => $matches[1],
+				'link'       => '',
+				'guid'       => '',
+				'profile'    => '',
+			];
+		} else {
+			$shared = BBCode::fetchShareAttributes($item['body']);
+			if (empty($shared['link']) && empty($shared['message_id'])) {
+				return $item['body'];
+			}	
 		}
 
 		$id = self::fetchByLink($shared['link'] ?: $shared['message_id']);