From de0ddfa0d88f4c227819dd90a5ea2fbf23dbd515 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 11 Nov 2018 21:54:50 +0000 Subject: [PATCH 1/2] Fix wromg server detecting / improved Pleroma version numbers --- mod/admin.php | 23 +++++++++++++++++++++++ src/Network/CurlResult.php | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/mod/admin.php b/mod/admin.php index 5adc8e9c47..91b21ace55 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -651,6 +651,29 @@ function admin_page_federation(App $a) $v[$key] = ['total' => $v[$key]['total'], 'version' => L10n::t('unknown')]; } } + + // Reformat and compact version numbers + if ($p == 'Pleroma') { + $compacted = []; + + foreach ($v as $key => $value) { + $version = $v[$key]['version']; + $parts = explode(' ', trim($version)); + do { + $part = array_pop($parts); + } while (!empty($parts) && ((strlen($part) >= 40) || (strlen($part) <= 3))); + + if (!empty($part)) { + $compacted[$part] += $v[$key]['total']; + } + } + + $v = []; + foreach ($compacted as $version => $total) { + $v[] = ['version' => $version, 'total' => $total]; + } + } + // in the DB the Diaspora versions have the format x.x.x.x-xx the last // part (-xx) should be removed to clean up the versions from the "head // commit" information and combined into a single entry for x.x.x.x diff --git a/src/Network/CurlResult.php b/src/Network/CurlResult.php index bbae881b88..7bf9ad87da 100644 --- a/src/Network/CurlResult.php +++ b/src/Network/CurlResult.php @@ -133,6 +133,11 @@ class CurlResult { $this->isSuccess = ($this->returnCode >= 200 && $this->returnCode <= 299) || $this->errorNumber == 0; + // Everything higher than 299 is not an success + if ($this->returnCode > 299) { + $this->isSuccess = false; + } + if (!$this->isSuccess) { Logger::log('error: ' . $this->url . ': ' . $this->returnCode . ' - ' . $this->error, Logger::INFO); Logger::log('debug: ' . print_r($this->info, true), Logger::DATA); From 0937c66484adce8fc2339178fd12a80f4ce54c9f Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 12 Nov 2018 04:12:36 +0000 Subject: [PATCH 2/2] A redirect is not an error --- src/Network/CurlResult.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Network/CurlResult.php b/src/Network/CurlResult.php index 7bf9ad87da..dd98853ae8 100644 --- a/src/Network/CurlResult.php +++ b/src/Network/CurlResult.php @@ -133,8 +133,8 @@ class CurlResult { $this->isSuccess = ($this->returnCode >= 200 && $this->returnCode <= 299) || $this->errorNumber == 0; - // Everything higher than 299 is not an success - if ($this->returnCode > 299) { + // Everything higher or equal 400 is not a success + if ($this->returnCode >= 400) { $this->isSuccess = false; }