]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/GServer.php
Fix phpcbf style errors in part of code I didn't change
[friendica.git] / src / Model / GServer.php
index 468978d10c3ae867275de1ef88a834a49ad75656..0a3590419b59f499890f259ed0ccf741ba4a950e 100644 (file)
@@ -455,19 +455,12 @@ class GServer
         * Set failed server status
         *
         * @param string $url
+        * @return void
         */
        public static function setFailureByUrl(string $url)
        {
                $nurl = Strings::normaliseLink($url);
 
-               if (Network::isUrlBlocked($url)) {
-                       Logger::info('Server domain is blocked', ['url' => $url]);
-                       return;
-               } elseif (Network::isUrlBlocked($nurl)) {
-                       Logger::info('Server domain is blocked', ['nurl' => $nurl]);
-                       return;
-               }
-
                $gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
                if (DBA::isResult($gserver)) {
                        $next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
@@ -567,13 +560,10 @@ class GServer
                // If the URL missmatches, then we mark the old entry as failure
                if (!Strings::compareLink($url, $original_url)) {
                        self::setFailureByUrl($original_url);
-                       if (!self::getID($url, true)) {
+                       if (!self::getID($url, true) && !Network::isUrlBlocked($url)) {
                                self::detect($url, $network, $only_nodeinfo);
                        }
                        return false;
-               } elseif (Network::isUrlBlocked($url)) {
-                       Logger::info('Server domain is blocked', ['url' => $url]);
-                       return false;
                }
 
                $valid_url = Network::isUrlValid($url);
@@ -591,7 +581,7 @@ class GServer
                                (((parse_url($url, PHP_URL_HOST) != parse_url($valid_url, PHP_URL_HOST)) || (parse_url($url, PHP_URL_PATH) != parse_url($valid_url, PHP_URL_PATH))) && empty(parse_url($valid_url, PHP_URL_PATH)))) {
                                Logger::debug('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $valid_url]);
                                self::setFailureByUrl($url);
-                               if (!self::getID($valid_url, true)) {
+                               if (!self::getID($valid_url, true) && !Network::isUrlBlocked($valid_url)) {
                                        self::detect($valid_url, $network, $only_nodeinfo);
                                }
                                return false;
@@ -605,7 +595,7 @@ class GServer
                                $valid_url = (string)Uri::fromParts($parts);
 
                                self::setFailureByUrl($url);
-                               if (!self::getID($valid_url, true)) {
+                               if (!self::getID($valid_url, true) && !Network::isUrlBlocked($valid_url)) {
                                        self::detect($valid_url, $network, $only_nodeinfo);
                                }
                                return false;
@@ -1070,10 +1060,11 @@ class GServer
                                Logger::info('Invalid nodeinfo format', ['url' => $url]);
                                continue;
                        }
+
                        if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
-                               $nodeinfo1_url = $link['href'];
+                               $nodeinfo1_url = Network::addBasePath($link['href'], $httpResult->getUrl());
                        } elseif ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0') {
-                               $nodeinfo2_url = $link['href'];
+                               $nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
                        }
                }
 
@@ -1426,7 +1417,7 @@ class GServer
                        $serverdata['detection-method'] = self::DETECT_SITEINFO_JSON;
                }
 
-               if (!empty($data['url'])) {
+               if (!empty($data['platform'])) {
                        $serverdata['platform'] = strtolower($data['platform']);
                        $serverdata['version'] = $data['version'] ?? 'N/A';
                }