]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Processor.php
Merge remote-tracking branch 'upstream/develop' into personal-copy
[friendica.git] / src / Protocol / ActivityPub / Processor.php
index 0ff2a588ea8a84a089ddaee89d6934eaac8e5ef3..7c40105e20a385def29ddc6076f83548500af177 100644 (file)
@@ -115,10 +115,22 @@ class Processor
                                                        continue 2;
                                                }
 
+                                               $item['body'] .= "\n";
+
+                                               // image is the preview/thumbnail URL
+                                               if (!empty($attach['image'])) {
+                                                       $item['body'] .= '[url=' . $attach['url'] . ']';
+                                                       $attach['url'] = $attach['image'];
+                                               }
+
                                                if (empty($attach['name'])) {
-                                                       $item['body'] .= "\n[img]" . $attach['url'] . '[/img]';
+                                                       $item['body'] .= '[img]' . $attach['url'] . '[/img]';
                                                } else {
-                                                       $item['body'] .= "\n[img=" . $attach['url'] . ']' . $attach['name'] . '[/img]';
+                                                       $item['body'] .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
+                                               }
+
+                                               if (!empty($attach['image'])) {
+                                                       $item['body'] .= '[/url]';
                                                }
                                        } elseif ($filetype == 'audio') {
                                                if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
@@ -502,6 +514,10 @@ class Processor
         */
        public static function postItem(array $activity, array $item)
        {
+               if (empty($item)) {
+                       return;
+               }
+
                $stored = false;
 
                foreach ($activity['receiver'] as $receiver) {
@@ -683,7 +699,7 @@ class Processor
         * @return string fetched message URL
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function fetchMissingActivity($url, $child = [])
+       public static function fetchMissingActivity(string $url, array $child = [])
        {
                if (!empty($child['receiver'])) {
                        $uid = ActivityPub\Receiver::getFirstUserFromReceivers($child['receiver']);