|
|
|
@ -34,6 +34,8 @@ use OCP\AppFramework\Http\DataResponse; |
|
|
|
|
use OCP\AppFramework\OCSController; |
|
|
|
|
use OCP\IConfig; |
|
|
|
|
use OCP\IRequest; |
|
|
|
|
use OCP\IUserSession; |
|
|
|
|
use OCP\L10N\IFactory; |
|
|
|
|
|
|
|
|
|
class APIController extends OCSController { |
|
|
|
|
|
|
|
|
@ -46,23 +48,29 @@ class APIController extends OCSController { |
|
|
|
|
/** @var AppFetcher */ |
|
|
|
|
protected $appFetcher; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $appName |
|
|
|
|
* @param IRequest $request |
|
|
|
|
* @param IConfig $config |
|
|
|
|
* @param IAppManager $appManager |
|
|
|
|
* @param AppFetcher $appFetcher |
|
|
|
|
*/ |
|
|
|
|
public function __construct($appName, |
|
|
|
|
/** @var IFactory */ |
|
|
|
|
protected $l10nFactory; |
|
|
|
|
|
|
|
|
|
/** @var IUserSession */ |
|
|
|
|
protected $userSession; |
|
|
|
|
|
|
|
|
|
/** @var string */ |
|
|
|
|
protected $language; |
|
|
|
|
|
|
|
|
|
public function __construct(string $appName, |
|
|
|
|
IRequest $request, |
|
|
|
|
IConfig $config, |
|
|
|
|
IAppManager $appManager, |
|
|
|
|
AppFetcher $appFetcher) { |
|
|
|
|
AppFetcher $appFetcher, |
|
|
|
|
IFactory $l10nFactory, |
|
|
|
|
IUserSession $userSession) { |
|
|
|
|
parent::__construct($appName, $request); |
|
|
|
|
|
|
|
|
|
$this->config = $config; |
|
|
|
|
$this->appManager = $appManager; |
|
|
|
|
$this->appFetcher = $appFetcher; |
|
|
|
|
$this->l10nFactory = $l10nFactory; |
|
|
|
|
$this->userSession = $userSession; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -97,7 +105,7 @@ class APIController extends OCSController { |
|
|
|
|
$this->appFetcher->setVersion($newVersion, 'future-apps.json', false); |
|
|
|
|
|
|
|
|
|
// Apps available on the app store for that version |
|
|
|
|
$availableApps = array_map(function (array $app) { |
|
|
|
|
$availableApps = array_map(static function (array $app) { |
|
|
|
|
return $app['id']; |
|
|
|
|
}, $this->appFetcher->get()); |
|
|
|
|
|
|
|
|
@ -108,6 +116,8 @@ class APIController extends OCSController { |
|
|
|
|
], Http::STATUS_NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->language = $this->l10nFactory->getUserLanguage($this->userSession->getUser()); |
|
|
|
|
|
|
|
|
|
$missing = array_diff($installedApps, $availableApps); |
|
|
|
|
$missing = array_map([$this, 'getAppDetails'], $missing); |
|
|
|
|
sort($missing); |
|
|
|
@ -128,8 +138,8 @@ class APIController extends OCSController { |
|
|
|
|
* @param string $appId |
|
|
|
|
* @return string[] |
|
|
|
|
*/ |
|
|
|
|
protected function getAppDetails($appId): array { |
|
|
|
|
$app = $this->appManager->getAppInfo($appId); |
|
|
|
|
protected function getAppDetails(string $appId): array { |
|
|
|
|
$app = $this->appManager->getAppInfo($appId, false, $this->language); |
|
|
|
|
return [ |
|
|
|
|
'appId' => $appId, |
|
|
|
|
'appName' => $app['name'] ?? $appId, |
|
|
|
|