]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Revert "Rename contact table column to ffi_keyword_denylist"
[friendica.git] / src / Protocol / OStatus.php
index 80644329ff4d857fc05269ce23e10be935214316..fa93b0e827ecd9b3644b6f83ba4b9ed075d80151 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2023, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -385,12 +385,14 @@ class OStatus
                        }
                }
 
-               $header = [];
-               $header['uid'] = $importer['uid'];
-               $header['network'] = Protocol::OSTATUS;
-               $header['wall'] = 0;
-               $header['origin'] = 0;
-               $header['gravity'] = Item::GRAVITY_COMMENT;
+               // Initial header elements
+               $header = [
+                       'uid'     => $importer['uid'],
+                       'network' => Protocol::OSTATUS,
+                       'wall'    => 0,
+                       'origin'  => 0,
+                       'gravity' => Item::GRAVITY_COMMENT,
+               ];
 
                if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
                        return false;
@@ -496,7 +498,7 @@ class OStatus
                                $orig_uri = $xpath->query('activity:object/atom:id', $entry)->item(0)->nodeValue;
                                Logger::notice('Favorite', ['uri' => $orig_uri, 'item' => $item]);
 
-                               $item['verb'] = Activity::LIKE;
+                               $item['body'] = $item['verb'] = Activity::LIKE;
                                $item['thr-parent'] = $orig_uri;
                                $item['gravity'] = Item::GRAVITY_ACTIVITY;
                                $item['object-type'] = Activity\ObjectType::NOTE;
@@ -734,7 +736,7 @@ class OStatus
                $stored = false;
                $curlResult = DI::httpClient()->get($related, HttpClientAccept::ATOM_XML);
 
-               if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
+               if (!$curlResult->isSuccess() || empty($curlResult->getBodyString())) {
                        return;
                }
 
@@ -743,12 +745,12 @@ class OStatus
                if ($curlResult->inHeader('Content-Type') &&
                        in_array('application/atom+xml', $curlResult->getHeader('Content-Type'))) {
                        Logger::info('Directly fetched XML for URI ' . $related_uri);
-                       $xml = $curlResult->getBody();
+                       $xml = $curlResult->getBodyString();
                }
 
                if ($xml == '') {
                        $doc = new DOMDocument();
-                       if (!@$doc->loadHTML($curlResult->getBody())) {
+                       if (!@$doc->loadHTML($curlResult->getBodyString())) {
                                return;
                        }
                        $xpath = new DOMXPath($doc);
@@ -768,7 +770,7 @@ class OStatus
 
                                        if ($curlResult->isSuccess()) {
                                                Logger::info('Fetched XML for URI ' . $related_uri);
-                                               $xml = $curlResult->getBody();
+                                               $xml = $curlResult->getBodyString();
                                        }
                                }
                        }
@@ -780,7 +782,7 @@ class OStatus
 
                        if ($curlResult->isSuccess()) {
                                Logger::info('GNU Social workaround to fetch XML for URI ' . $related_uri);
-                               $xml = $curlResult->getBody();
+                               $xml = $curlResult->getBodyString();
                        }
                }
 
@@ -791,7 +793,7 @@ class OStatus
 
                        if ($curlResult->isSuccess()) {
                                Logger::info('GNU Social workaround 2 to fetch XML for URI ' . $related_uri);
-                               $xml = $curlResult->getBody();
+                               $xml = $curlResult->getBodyString();
                        }
                }
 
@@ -1468,6 +1470,8 @@ class OStatus
                        $entry = $doc->createElement('entry');
 
                        if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
+                               $entry->setAttribute('xmlns:activity', ActivityNamespace::ACTIVITY);
+
                                $contact = Contact::getByURL($item['author-link']) ?: $owner;
                                $contact['nickname'] = $contact['nickname'] ?? $contact['nick'];
                                $author = self::addAuthor($doc, $contact, false);
@@ -1515,6 +1519,7 @@ class OStatus
                XML::addElement($doc, $entry, 'title', html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
 
                $body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
+               $body = Post\Media::addHTMLLinkToBody($item['uri-id'], $body);
 
                if (!empty($item['title'])) {
                        $body = '[b]' . $item['title'] . "[/b]\n\n" . $body;
@@ -1708,7 +1713,7 @@ class OStatus
 
                $previous_created = $last_update;
 
-               // Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
+               // Don't cache when the last item was posted less than 15 minutes ago (Cache duration)
                if ((time() - strtotime($owner['last-item'])) < 15*60) {
                        $result = DI::cache()->get($cachekey);
                        if (!$nocache && !is_null($result)) {