Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add ocs route to get apps enabled for current user
Signed-off-by: Jana Peper <[email protected]>
  • Loading branch information
janepie committed Jun 18, 2025
commit 50c9852e240727e1aa8c0fc982e9d997a99a192e
1 change: 1 addition & 0 deletions apps/provisioning_api/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
['root' => '/cloud', 'name' => 'Users#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
['root' => '/cloud', 'name' => 'Users#getEditableFields', 'url' => '/user/fields', 'verb' => 'GET'],
['root' => '/cloud', 'name' => 'Users#getEditableFieldsForUser', 'url' => '/user/fields/{userId}', 'verb' => 'GET'],
['root' => '/cloud', 'name' => 'Users#getEnabledApps', 'url' => '/user/apps', 'verb' => 'GET'],
['root' => '/cloud', 'name' => 'Users#editUser', 'url' => '/users/{userId}', 'verb' => 'PUT'],
['root' => '/cloud', 'name' => 'Users#editUserMultiValue', 'url' => '/users/{userId}/{collectionName}', 'verb' => 'PUT', 'requirements' => ['collectionName' => '^(?!enable$|disable$)[a-zA-Z0-9_]*$']],
['root' => '/cloud', 'name' => 'Users#wipeUserDevices', 'url' => '/users/{userId}/wipe', 'verb' => 'POST'],
Expand Down
15 changes: 15 additions & 0 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
Expand Down Expand Up @@ -79,6 +80,7 @@ public function __construct(
private KnownUserService $knownUserService,
private IEventDispatcher $eventDispatcher,
private IPhoneNumberUtil $phoneNumberUtil,
private IAppManager $appManager,
) {
parent::__construct(
$appName,
Expand Down Expand Up @@ -709,6 +711,19 @@ public function getEditableFields(): DataResponse {
return $this->getEditableFieldsForUser($currentLoggedInUser->getUID());
}

/**
* Get a list of enabled apps for the current user
*
* @return DataResponse<Http::STATUS_OK, array{apps: list<string>}, array{}>
*
* 200: Enabled apps returned
*/
#[NoAdminRequired]
public function getEnabledApps(): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
return new DataResponse(['apps' => $this->appManager->getEnabledAppsForUser($currentLoggedInUser)]);
}

/**
* @NoSubAdminRequired
*
Expand Down
2 changes: 1 addition & 1 deletion lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function getAllAppsInAppsFolders(): array {
* List all apps enabled for a user
*
* @param \OCP\IUser $user
* @return string[]
* @return list<string>
*/
public function getEnabledAppsForUser(IUser $user) {
$apps = $this->getEnabledAppsValues();
Expand Down
2 changes: 1 addition & 1 deletion lib/public/App/IAppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function getAppWebPath(string $appId): string;
* List all apps enabled for a user
*
* @param \OCP\IUser $user
* @return string[]
* @return list<string>
* @since 8.1.0
*/
public function getEnabledAppsForUser(IUser $user);
Expand Down