]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
The GNU-Social import is removed
[friendica.git] / src / Protocol / OStatus.php
index bd6002392a5659b3d24950f924ec97ae2e93d106..81a0c38842edcc77ad8d298486e254da4f091f45 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Protocol;
 use DOMDocument;
 use DOMElement;
 use DOMXPath;
+use Friendica\App;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
 use Friendica\Core\Cache\Enum\Duration;
@@ -102,9 +103,9 @@ class OStatus
 */
                if ($aliaslink != '') {
                        $contact = DBA::selectFirst('contact', [], [
-                               "`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
+                               "`uid` = ? AND `alias` = ? AND `rel` IN (?, ?)",
                                $importer['uid'],
-                               $aliaslink, Protocol::STATUSNET,
+                               $aliaslink,
                                Contact::SHARING, Contact::FRIEND,
                        ]);
                }
@@ -115,11 +116,10 @@ class OStatus
                        }
 
                        $contact = DBA::selectFirst('contact', [], [
-                               "`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
+                               "`uid` = ? AND `nurl` IN (?, ?) AND `rel` IN (?, ?)",
                                $importer['uid'],
                                Strings::normaliseLink($author['author-link']),
                                Strings::normaliseLink($aliaslink),
-                               Protocol::STATUSNET,
                                Contact::SHARING,
                                Contact::FRIEND,
                        ]);
@@ -127,10 +127,9 @@ class OStatus
 
                if (!DBA::isResult($contact) && ($addr != '')) {
                        $contact = DBA::selectFirst('contact', [], [
-                               "`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
+                               "`uid` = ? AND `addr` = ? AND `rel` IN (?, ?)",
                                $importer['uid'],
                                $addr,
-                               Protocol::STATUSNET,
                                Contact::SHARING,
                                Contact::FRIEND,
                        ]);
@@ -391,7 +390,7 @@ class OStatus
                $header['network'] = Protocol::OSTATUS;
                $header['wall'] = 0;
                $header['origin'] = 0;
-               $header['gravity'] = GRAVITY_COMMENT;
+               $header['gravity'] = Item::GRAVITY_COMMENT;
 
                if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
                        return false;
@@ -499,7 +498,7 @@ class OStatus
 
                                $item['verb'] = Activity::LIKE;
                                $item['thr-parent'] = $orig_uri;
-                               $item['gravity'] = GRAVITY_ACTIVITY;
+                               $item['gravity'] = Item::GRAVITY_ACTIVITY;
                                $item['object-type'] = Activity\ObjectType::NOTE;
                        }
 
@@ -714,7 +713,7 @@ class OStatus
                        }
                } else {
                        $item['thr-parent'] = $item['uri'];
-                       $item['gravity'] = GRAVITY_PARENT;
+                       $item['gravity'] = Item::GRAVITY_PARENT;
                }
 
                self::$itemlist[] = $item;
@@ -1061,9 +1060,9 @@ class OStatus
 
                $attributes = [
                        'uri' => 'https://friendi.ca',
-                       'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
+                       'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
                ];
-               XML::addElement($doc, $root, 'generator', FRIENDICA_PLATFORM, $attributes);
+               XML::addElement($doc, $root, 'generator', App::PLATFORM, $attributes);
                XML::addElement($doc, $root, 'id', DI::baseUrl() . '/profile/' . $owner['nick']);
                XML::addElement($doc, $root, 'title', $title);
                XML::addElement($doc, $root, 'subtitle', sprintf("Updates from %s on %s", $owner['name'], DI::config()->get('config', 'sitename')));
@@ -1185,7 +1184,7 @@ class OStatus
                        }
                }
 
-               foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) {
+               foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT]) as $attachment) {
                        $attributes = ['rel' => 'enclosure',
                                'href' => $attachment['url'],
                                'type' => $attachment['mimetype']];
@@ -1359,7 +1358,7 @@ class OStatus
         */
        private static function likeEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
        {
-               if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
+               if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
                        Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
                }
 
@@ -1509,7 +1508,7 @@ class OStatus
         */
        private static function noteEntry(DOMDocument $doc, array $item, array $owner, bool $toplevel): DOMElement
        {
-               if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
+               if (($item['gravity'] != Item::GRAVITY_PARENT) && (Strings::normaliseLink($item['author-link']) != Strings::normaliseLink($owner['url']))) {
                        Logger::info('OStatus entry is from author ' . $owner['url'] . ' - not from ' . $item['author-link'] . '. Quitting.');
                }
 
@@ -1597,7 +1596,7 @@ class OStatus
                XML::addElement($doc, $entry, 'id', $item['uri']);
                XML::addElement($doc, $entry, 'title', html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
 
-               $body = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
+               $body = Post\Media::addAttachmentsToBody($item['uri-id'], DI::contentItem()->addSharedPost($item));
                $body = self::formatPicturePost($body, $item['uri-id']);
 
                if (!empty($item['title'])) {
@@ -1639,7 +1638,7 @@ class OStatus
        {
                $mentioned = [];
 
-               if ($item['gravity'] != GRAVITY_PARENT) {
+               if ($item['gravity'] != Item::GRAVITY_PARENT) {
                        $parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
 
                        $thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);