diff options
author | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2023-07-07 09:51:08 +0200 |
---|---|---|
committer | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2023-07-21 12:06:49 +0200 |
commit | 25ba08b1d3ae635ee486ac32cbda86c2b1ec46fe (patch) | |
tree | 56453ebdf92ca742239013da18fd13f164e6051f /lib/private | |
parent | ff3442d917722f51d7896b7e2f789c4de5fb08dd (diff) | |
download | nextcloud-server-25ba08b1d3ae635ee486ac32cbda86c2b1ec46fe.tar.gz nextcloud-server-25ba08b1d3ae635ee486ac32cbda86c2b1ec46fe.zip |
Add instance category while checking new updates
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Updater/VersionCheck.php | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index 3abbae682b5..d4a3a843314 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); + } } |