]> git.mxchange.org Git - friendica.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 21 Jan 2023 00:04:31 +0000 (01:04 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 21 Jan 2023 00:07:14 +0000 (01:07 +0100)
- moved if() block to suggested position by MrPetovan, for me I want to have all
  conditions checked at the start of the method, e.g. no unwanted null
  references or (in this case) if the URL is blacklisted
- normalized URLs are without SSL, means http://host/path/file.ext so they exist
  only once for contacts and servers (aka. instances)
- documented returned type `void`

src/Model/GServer.php
src/Worker/UpdateServerPeers.php

index 468978d10c3ae867275de1ef88a834a49ad75656..41edb6c8d271568e47b5647809d9b80649fc28c7 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']);
@@ -481,6 +474,14 @@ class GServer
                        return;
                }
 
+               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;
+               }
+
                self::insert(['url' => $url, 'nurl' => $nurl,
                        'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
                        'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
index 8119030a17bdd2bf0f21c9727232ef82a70b9754..51f8b4b7676abcc09e0f7f60af9470fbb0b35445 100644 (file)
@@ -63,7 +63,7 @@ class UpdateServerPeers
                        }
 
                        ++$total;
-                       if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink('https://' . $peer)])) {
+                       if (DBA::exists('gserver', ['nurl' => 'http://' . $peer])) {
                                // We already know this server
                                continue;
                        }