aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2023-07-27 12:04:52 +0200
committerGitHub <noreply@github.com>2023-07-27 12:04:52 +0200
commit5fbb3bb7f0ad070bf541a1401d1bc98f8b516722 (patch)
tree724fb4c2db10db8d4977eef331866b2758b594ef /lib
parentd0ac2b4494c0135b400ff8c19f7865edc6f87530 (diff)
parent46b462285d9f377348b33d44924827fb11a14e32 (diff)
downloadnextcloud-server-5fbb3bb7f0ad070bf541a1401d1bc98f8b516722.tar.gz
nextcloud-server-5fbb3bb7f0ad070bf541a1401d1bc98f8b516722.zip
Merge pull request #39522 from nextcloud/backport/39264/stable27
[stable27] Add instance category while checking new updates
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Updater/VersionCheck.php45
1 files changed, 31 insertions, 14 deletions
diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php
index a634ae4cc71..2aab260716a 100644
--- a/lib/private/Updater/VersionCheck.php
+++ b/lib/private/Updater/VersionCheck.php
@@ -28,23 +28,17 @@ namespace OC\Updater;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\IUserManager;
+use OCP\Support\Subscription\IRegistry;
use OCP\Util;
class VersionCheck {
- /** @var IClientService */
- private $clientService;
-
- /** @var IConfig */
- private $config;
-
- /**
- * @param IClientService $clientService
- * @param IConfig $config
- */
- public function __construct(IClientService $clientService,
- IConfig $config) {
- $this->clientService = $clientService;
- $this->config = $config;
+ public function __construct(
+ private IClientService $clientService,
+ private IConfig $config,
+ private IUserManager $userManager,
+ private IRegistry $registry,
+ ) {
}
@@ -81,6 +75,8 @@ class VersionCheck {
$version['php_major'] = PHP_MAJOR_VERSION;
$version['php_minor'] = PHP_MINOR_VERSION;
$version['php_release'] = PHP_RELEASE_VERSION;
+ $version['category'] = $this->computeCategory();
+ $version['isSubscriber'] = (int) $this->registry->delegateHasValidSubscription();
$versionString = implode('x', $version);
//fetch xml data from updater
@@ -130,4 +126,25 @@ class VersionCheck {
$response = $client->get($url);
return $response->getBody();
}
+
+ private function computeCategory(): int {
+ $categoryBoundaries = [
+ 100,
+ 500,
+ 1000,
+ 5000,
+ 10000,
+ 100000,
+ 1000000,
+ ];
+
+ $nbUsers = $this->userManager->countSeenUsers();
+ foreach ($categoryBoundaries as $categoryId => $boundary) {
+ if ($nbUsers <= $boundary) {
+ return $categoryId;
+ }
+ }
+
+ return count($categoryBoundaries);
+ }
}