diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-10-14 09:50:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 09:50:37 +0200 |
commit | 811d0cd1b5f3967571da9846892cdcd14c2eaaec (patch) | |
tree | 8595eb32ae4287b5a63c3dd1d571d9b945163418 /lib | |
parent | abc2472c5d63f2ebd0f165f812c4a2001232c63d (diff) | |
parent | c721581cd960c51bf25b85684d5327a08d8a6d42 (diff) | |
download | nextcloud-server-811d0cd1b5f3967571da9846892cdcd14c2eaaec.tar.gz nextcloud-server-811d0cd1b5f3967571da9846892cdcd14c2eaaec.zip |
Merge pull request #29135 from nextcloud/feat/appstore-filtering
Allow to filter apps from the appstore
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppStore/Fetcher/AppFetcher.php | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php index 1605e5bd230..7fa0c0c9ac5 100644 --- a/lib/private/App/AppStore/Fetcher/AppFetcher.php +++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php @@ -35,6 +35,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 AppFetcher extends Fetcher { @@ -42,6 +43,9 @@ class AppFetcher extends Fetcher { /** @var CompareVersion */ private $compareVersion; + /** @var IRegistry */ + private $registry; + /** @var bool */ private $ignoreMaxVersion; @@ -50,7 +54,8 @@ class AppFetcher extends Fetcher { ITimeFactory $timeFactory, IConfig $config, CompareVersion $compareVersion, - LoggerInterface $logger) { + LoggerInterface $logger, + IRegistry $registry) { parent::__construct( $appDataFactory, $clientService, @@ -59,9 +64,11 @@ class AppFetcher extends Fetcher { $logger ); + $this->compareVersion = $compareVersion; + $this->registry = $registry; + $this->fileName = 'apps.json'; $this->endpointName = 'apps.json'; - $this->compareVersion = $compareVersion; $this->ignoreMaxVersion = true; } @@ -172,4 +179,19 @@ class AppFetcher extends Fetcher { $this->fileName = $fileName; $this->ignoreMaxVersion = $ignoreMaxVersion; } + + + public function get($allowUnstable = false) { + $apps = parent::get($allowUnstable); + $allowList = $this->config->getSystemValue('appsallowlist'); + + // If the admin specified a allow list, filter apps from the appstore + if (is_array($allowList) && $this->registry->delegateHasValidSubscription()) { + return array_filter($apps, function ($app) use ($allowList) { + return in_array($app['id'], $allowList); + }); + } + + return $apps; + } } |