aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2021-10-15 11:06:32 +0200
committerGitHub <noreply@github.com>2021-10-15 11:06:32 +0200
commitb6a3ba136c4b69cedd613ceb36244656ae31941c (patch)
treebff8388e87630205c1f3ec10eb7bdc337dc284ed /lib
parent8df577ba0a706841399097301f9b802b7a24005d (diff)
parent1f76423500f2562892b87effc112947e162f8a28 (diff)
downloadnextcloud-server-b6a3ba136c4b69cedd613ceb36244656ae31941c.tar.gz
nextcloud-server-b6a3ba136c4b69cedd613ceb36244656ae31941c.zip
Merge pull request #29235 from nextcloud/feat/appstore/enterprise
Diffstat (limited to 'lib')
-rw-r--r--lib/private/App/AppStore/Fetcher/AppFetcher.php5
-rw-r--r--lib/private/App/AppStore/Fetcher/CategoryFetcher.php8
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php14
3 files changed, 22 insertions, 5 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index 7fa0c0c9ac5..6c201978e1f 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -44,7 +44,7 @@ class AppFetcher extends Fetcher {
private $compareVersion;
/** @var IRegistry */
- private $registry;
+ protected $registry;
/** @var bool */
private $ignoreMaxVersion;
@@ -61,7 +61,8 @@ class AppFetcher extends Fetcher {
$clientService,
$timeFactory,
$config,
- $logger
+ $logger,
+ $registry
);
$this->compareVersion = $compareVersion;
diff --git a/lib/private/App/AppStore/Fetcher/CategoryFetcher.php b/lib/private/App/AppStore/Fetcher/CategoryFetcher.php
index 8fd8529b662..afe051e6281 100644
--- a/lib/private/App/AppStore/Fetcher/CategoryFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/CategoryFetcher.php
@@ -30,6 +30,7 @@ use OC\Files\AppData\Factory;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\Support\Subscription\IRegistry;
use Psr\Log\LoggerInterface;
class CategoryFetcher extends Fetcher {
@@ -37,14 +38,17 @@ class CategoryFetcher extends Fetcher {
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
- LoggerInterface $logger) {
+ LoggerInterface $logger,
+ IRegistry $registry) {
parent::__construct(
$appDataFactory,
$clientService,
$timeFactory,
$config,
- $logger
+ $logger,
+ $registry
);
+
$this->fileName = 'categories.json';
$this->endpointName = 'categories.json';
}
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php
index a70fc20ba1e..c02d77dec46 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -38,6 +38,7 @@ use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\Support\Subscription\IRegistry;
use Psr\Log\LoggerInterface;
abstract class Fetcher {
@@ -54,6 +55,9 @@ abstract class Fetcher {
protected $config;
/** @var LoggerInterface */
protected $logger;
+ /** @var IRegistry */
+ protected $registry;
+
/** @var string */
protected $fileName;
/** @var string */
@@ -67,12 +71,14 @@ abstract class Fetcher {
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
- LoggerInterface $logger) {
+ LoggerInterface $logger,
+ IRegistry $registry) {
$this->appData = $appDataFactory->get('appstore');
$this->clientService = $clientService;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->logger = $logger;
+ $this->registry = $registry;
}
/**
@@ -103,6 +109,12 @@ abstract class Fetcher {
];
}
+ // If we have a valid subscription key, send it to the appstore
+ $subscriptionKey = $this->config->getAppValue('support', 'subscription_key');
+ if ($this->registry->delegateHasValidSubscription() && $subscriptionKey) {
+ $options['headers']['X-NC-Subscription-Key'] = $subscriptionKey;
+ }
+
$client = $this->clientService->newClient();
try {
$response = $client->get($this->getEndpoint(), $options);