]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Flatten conditions and add call to HTML::checkRelMeLink in Worker\CheckRelMeProfileLink
[friendica.git] / src / Protocol / Diaspora.php
index 3c60f4041ba98ae374dbcce1f5021bf6c5064e7b..86d88867b922397c415581df40312a7f2bac52e1 100644 (file)
@@ -499,7 +499,7 @@ class Diaspora
                }
 
                if (!($fields = self::validPosting($msg))) {
-                       Logger::warning('Invalid posting', ['msg' => $msg]);
+                       Logger::notice('Invalid posting', ['msg' => $msg]);
                        return false;
                }
 
@@ -826,9 +826,15 @@ class Diaspora
         */
        public static function isSupportedByContactUrl(string $url, ?bool $update = null): bool
        {
-               $contact = Contact::getByURL($url, $update);
+               $contact = Contact::getByURL($url, $update, ['uri-id', 'network']);
 
-               return DI::dsprContact()->existsByUriId($contact['uri-id'] ?? 0);
+               $supported = DI::dsprContact()->existsByUriId($contact['uri-id'] ?? 0);
+
+               if (!$supported && is_null($update) && ($contact['network'] == Protocol::DFRN)) {
+                       $supported = self::isSupportedByContactUrl($url, true);
+               }
+
+               return $supported;
        }
 
        /**
@@ -2279,65 +2285,6 @@ class Diaspora
                return true;
        }
 
-       /**
-        * Stores a reshare activity
-        *
-        * @param array        $item              Array of reshare post
-        * @param integer      $parent_message_id Id of the parent post
-        * @param string       $guid              GUID string of reshare action
-        * @param WebFingerUri $author            Author handle
-        * @return false|void
-        * @throws InternalServerErrorException
-        * @throws \ImagickException
-        */
-       private static function addReshareActivity(array $item, int $parent_message_id, string $guid, WebFingerUri $author)
-       {
-               $parent = Post::selectFirst(['uri', 'guid'], ['id' => $parent_message_id]);
-
-               $datarray = [];
-
-               $datarray['uid'] = $item['uid'];
-               $datarray['contact-id'] = $item['contact-id'];
-               $datarray['network'] = $item['network'];
-
-               $datarray['author-link'] = $item['author-link'];
-               $datarray['author-id'] = $item['author-id'];
-
-               $datarray['owner-link'] = $datarray['author-link'];
-               $datarray['owner-id'] = $datarray['author-id'];
-
-               $datarray['guid'] = $parent['guid'] . '-' . $guid;
-               $datarray['uri'] = self::getUriFromGuid($datarray['guid'], $author);
-               $datarray['thr-parent'] = $parent['uri'];
-
-               $datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
-               $datarray['gravity'] = Item::GRAVITY_ACTIVITY;
-               $datarray['object-type'] = Activity\ObjectType::NOTE;
-
-               $datarray['protocol'] = $item['protocol'];
-               $datarray['source'] = $item['source'];
-               $datarray['direction'] = $item['direction'];
-               $datarray['post-reason'] = $item['post-reason'];
-
-               $datarray['plink'] = self::plink($author, $datarray['guid']);
-               $datarray['private'] = $item['private'];
-               $datarray['changed'] = $datarray['created'] = $datarray['edited'] = $item['created'];
-
-               if (Item::isTooOld($datarray)) {
-                       Logger::info('Reshare activity is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
-                       return false;
-               }
-
-               $message_id = Item::insert($datarray);
-
-               if ($message_id) {
-                       Logger::info('Stored reshare activity.', ['guid' => $guid, 'id' => $message_id]);
-                       if ($datarray['uid'] == 0) {
-                               Item::distribute($message_id);
-                       }
-               }
-       }
-
        /**
         * Processes a reshare message
         *
@@ -2430,11 +2377,6 @@ class Diaspora
 
                self::sendParticipation($contact, $datarray);
 
-               $root_message_id = self::messageExists($importer['uid'], $root_guid);
-               if ($root_message_id) {
-                       self::addReshareActivity($datarray, $root_message_id, $guid, $author);
-               }
-
                if ($message_id) {
                        Logger::info('Stored reshare ' . $datarray['guid'] . ' with message id ' . $message_id);
                        if ($datarray['uid'] == 0) {
@@ -4064,7 +4006,7 @@ class Diaspora
                        return false;
                }
 
-               if (!self::isSupportedByContactUrl($parent_post['author-link'], false)) {
+               if (!self::isSupportedByContactUrl($parent_post['author-link'])) {
                        Logger::info('Parent author is no Diaspora contact.', ['parent-id' => $parent_id]);
                        return false;
                }