Skip to content

Commit a500569

Browse files
committed
feat: add ocs route to get apps enabled for current user
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
1 parent b95f96a commit a500569

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

apps/provisioning_api/appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
['root' => '/cloud', 'name' => 'Users#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
3636
['root' => '/cloud', 'name' => 'Users#getEditableFields', 'url' => '/user/fields', 'verb' => 'GET'],
3737
['root' => '/cloud', 'name' => 'Users#getEditableFieldsForUser', 'url' => '/user/fields/{userId}', 'verb' => 'GET'],
38+
['root' => '/cloud', 'name' => 'Users#getEnabledApps', 'url' => '/user/apps', 'verb' => 'GET'],
3839
['root' => '/cloud', 'name' => 'Users#editUser', 'url' => '/users/{userId}', 'verb' => 'PUT'],
3940
['root' => '/cloud', 'name' => 'Users#editUserMultiValue', 'url' => '/users/{userId}/{collectionName}', 'verb' => 'PUT', 'requirements' => ['collectionName' => '^(?!enable$|disable$)[a-zA-Z0-9_]*$']],
4041
['root' => '/cloud', 'name' => 'Users#wipeUserDevices', 'url' => '/users/{userId}/wipe', 'verb' => 'POST'],

apps/provisioning_api/lib/Controller/UsersController.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use OCP\Accounts\IAccountManager;
2222
use OCP\Accounts\IAccountProperty;
2323
use OCP\Accounts\PropertyDoesNotExistException;
24+
use OCP\App\IAppManager;
2425
use OCP\AppFramework\Http;
2526
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
2627
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -79,6 +80,7 @@ public function __construct(
7980
private KnownUserService $knownUserService,
8081
private IEventDispatcher $eventDispatcher,
8182
private IPhoneNumberUtil $phoneNumberUtil,
83+
private IAppManager $appManager,
8284
) {
8385
parent::__construct(
8486
$appName,
@@ -709,6 +711,19 @@ public function getEditableFields(): DataResponse {
709711
return $this->getEditableFieldsForUser($currentLoggedInUser->getUID());
710712
}
711713

714+
/**
715+
* Get a list of enabled apps for the current user
716+
*
717+
* @return DataResponse<Http::STATUS_OK, array{apps: list<string>}, array{}>
718+
*
719+
* 200: Enabled apps returned
720+
*/
721+
#[NoAdminRequired]
722+
public function getEnabledApps(): DataResponse {
723+
$currentLoggedInUser = $this->userSession->getUser();
724+
return new DataResponse(['apps' => $this->appManager->getEnabledAppsForUser($currentLoggedInUser)]);
725+
}
726+
712727
/**
713728
* @NoSubAdminRequired
714729
*

lib/public/App/IAppManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function getAppWebPath(string $appId): string;
184184
* List all apps enabled for a user
185185
*
186186
* @param \OCP\IUser $user
187-
* @return string[]
187+
* @return list<string>
188188
* @since 8.1.0
189189
*/
190190
public function getEnabledAppsForUser(IUser $user);

0 commit comments

Comments
 (0)