|
|
|
@ -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);
|
|
|
|
|