diff options
author | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2023-07-21 11:04:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 11:04:32 +0200 |
commit | e9b8a34cce59c7bd6ef6bec6b9c4846c062e4a7b (patch) | |
tree | 6dc36af91dc435a6397175873866eb4fb6d95cd0 /lib/private | |
parent | fefc079bd6e59583d6b7147c85fe2d8f30b38a77 (diff) | |
parent | 31f135477792902c3b7380fba6406202e7815ca1 (diff) | |
download | nextcloud-server-e9b8a34cce59c7bd6ef6bec6b9c4846c062e4a7b.tar.gz nextcloud-server-e9b8a34cce59c7bd6ef6bec6b9c4846c062e4a7b.zip |
Merge pull request #39264 from nextcloud/feat/add-instance-category
Add instance category while checking new updates
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 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); + } } |