aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
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);
+ }
}