diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2021-10-08 11:35:27 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2021-10-13 11:13:33 +0200 |
commit | 1a6bac58747165b3d8a8304e7ebaeb296b6e07a8 (patch) | |
tree | 89d4b8b4f5b32aece60ceb1dbb877275bad4f978 /lib/private/App/AppStore/Fetcher | |
parent | 682944925839e5300c02a231b261bb6fc6dfdf20 (diff) | |
download | nextcloud-server-1a6bac58747165b3d8a8304e7ebaeb296b6e07a8.tar.gz nextcloud-server-1a6bac58747165b3d8a8304e7ebaeb296b6e07a8.zip |
Allow to whitelist apps from the apsptore
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/App/AppStore/Fetcher')
-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..2216999e12f 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); + $whitelist = $this->config->getSystemValue('appsallowlist'); + + // If the admin specified a whitelist, filter apps from the appstore + if (is_array($whitelist) && $this->registry->delegateHasValidSubscription()) { + return array_filter($apps, function ($app) use ($whitelist) { + return in_array($app['id'], $whitelist); + }); + } + + return $apps; + } } |