@@ -82,12 +82,13 @@ public function listCategories(): DataResponse {
8282 /**
8383 * Get all available apps
8484 *
85+ * @param bool $details - Whether to include detailed appstore information about the app
8586 * @return DataResponse<Http::STATUS_OK, list<array{id: string, name: string, groups: list<string>, internal: bool, isCompatible: bool, missingDependencies?: list<string>, missingMaxNextcloudVersion: bool, missingMinNextcloudVersion: bool, ...<array-key, mixed>}>, array{}>
8687 *
8788 * 200: The apps were found successfully
8889 */
8990 #[ApiRoute(verb: 'GET ' , url: '/api/v1/apps ' )]
90- public function listApps (): DataResponse {
91+ public function listApps (bool $ details = false ): DataResponse {
9192 $ apps = $ this ->getAllApps ();
9293
9394 /** @var array<string>|mixed $ignoreMaxApps */
@@ -98,12 +99,16 @@ public function listApps(): DataResponse {
9899 }
99100
100101 // Extend existing app details
101- $ apps = array_map (function (array $ appData ) use ($ ignoreMaxApps ): array {
102+ $ apps = array_map (function (array $ appData ) use ($ ignoreMaxApps, $ details ): array {
102103 if (isset ($ appData ['appstoreData ' ])) {
103104 $ appstoreData = $ appData ['appstoreData ' ];
104105 $ appData ['screenshot ' ] = $ this ->createProxyPreviewUrl ($ appstoreData ['screenshots ' ][0 ]['url ' ] ?? '' );
105106 $ appData ['category ' ] = $ appstoreData ['categories ' ];
106107 $ appData ['releases ' ] = $ appstoreData ['releases ' ];
108+
109+ if (!$ details ) {
110+ unset($ appData ['appstoreData ' ]);
111+ }
107112 }
108113
109114 $ newVersion = $ this ->installer ->isUpdateAvailable ($ appData ['id ' ]);
@@ -123,17 +128,15 @@ public function listApps(): DataResponse {
123128 }
124129
125130 $ appData ['groups ' ] = $ groups ;
126- $ appData ['canUninstall ' ] = !$ appData ['active ' ] && $ appData ['removable ' ];
127-
128131 // analyze dependencies
129132 $ ignoreMax = in_array ($ appData ['id ' ], $ ignoreMaxApps );
130133 $ missing = $ this ->dependencyAnalyzer ->analyze ($ appData , $ ignoreMax );
131- $ appData ['canInstall ' ] = empty ($ missing );
132134 $ appData ['missingDependencies ' ] = $ missing ;
133135
134136 $ appData ['missingMinNextcloudVersion ' ] = !isset ($ appData ['dependencies ' ]['nextcloud ' ]['@attributes ' ]['min-version ' ]);
135137 $ appData ['missingMaxNextcloudVersion ' ] = !isset ($ appData ['dependencies ' ]['nextcloud ' ]['@attributes ' ]['max-version ' ]);
136138 $ appData ['isCompatible ' ] = $ this ->dependencyAnalyzer ->isMarkedCompatible ($ appData );
139+ $ appData ['internal ' ] = in_array ($ appData ['id ' ], $ this ->appManager ->getAlwaysEnabledApps ());
137140
138141 return $ appData ;
139142 }, $ apps );
@@ -204,6 +207,7 @@ public function enableApp(string $appId, array $groups = [], bool $force = false
204207 public function disableApp (string $ appId ): DataResponse {
205208 try {
206209 $ appId = $ this ->appManager ->cleanAppId ($ appId );
210+ $ this ->appManager ->removeOverwriteNextcloudRequirement ($ appId );
207211 $ this ->appManager ->disableApp ($ appId );
208212 return new DataResponse ([]);
209213 } catch (\Exception $ exception ) {
@@ -214,7 +218,6 @@ public function disableApp(string $appId): DataResponse {
214218
215219 /**
216220 * Uninstall an app.
217- * This will disable the app - if needed - and then remove the app from the system
218221 *
219222 * @param string $appId - The app to uninstall
220223 * @return DataResponse<Http::STATUS_OK, array{}, array{}>
@@ -226,6 +229,10 @@ public function disableApp(string $appId): DataResponse {
226229 #[ApiRoute(verb: 'POST ' , url: '/api/v1/apps/uninstall ' )]
227230 public function uninstallApp (string $ appId ): DataResponse {
228231 $ appId = $ this ->appManager ->cleanAppId ($ appId );
232+ if ($ this ->appManager ->isEnabledForAnyone ($ appId )) {
233+ $ this ->disableApp ($ appId );
234+ }
235+
229236 $ result = $ this ->installer ->removeApp ($ appId );
230237 if ($ result !== false ) {
231238 // If this app was force enabled, remove the force-enabled-state
@@ -452,6 +459,7 @@ private function getAppsForCategory(string $requestedCategory = ''): array {
452459 'license ' => $ app ['releases ' ][0 ]['licenses ' ],
453460 'author ' => $ authors ,
454461 'shipped ' => $ this ->appManager ->isShipped ($ app ['id ' ]),
462+ 'internal ' => in_array ($ app ['id ' ], $ this ->appManager ->getAlwaysEnabledApps ()),
455463 'version ' => $ currentVersion ,
456464 'types ' => [],
457465 'documentation ' => [
@@ -468,11 +476,9 @@ private function getAppsForCategory(string $requestedCategory = ''): array {
468476 'level ' => ($ app ['isFeatured ' ] === true ) ? 200 : 100 ,
469477 'missingMaxNextcloudVersion ' => false ,
470478 'missingMinNextcloudVersion ' => false ,
471- 'canInstall ' => true ,
472479 'screenshot ' => isset ($ app ['screenshots ' ][0 ]['url ' ]) ? 'https://usercontent.apps.nextcloud.com/ ' . base64_encode ($ app ['screenshots ' ][0 ]['url ' ]) : '' ,
473- 'score ' => $ app ['ratingOverall ' ],
480+ 'ratingOverall ' => $ app ['ratingOverall ' ],
474481 'ratingNumOverall ' => $ app ['ratingNumOverall ' ],
475- 'ratingNumThresholdReached ' => $ app ['ratingNumOverall ' ] > 5 ,
476482 'removable ' => $ existsLocally ,
477483 'active ' => $ this ->appManager ->isEnabledForUser ($ app ['id ' ]),
478484 'needsDownload ' => !$ existsLocally ,
0 commit comments