-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: provokateurin <kate@provokateurin.de>
- Loading branch information
1 parent
3ee463a
commit abcd329
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Recommendations; | ||
|
||
use OCA\Recommendations\AppInfo\Application; | ||
use OCP\Capabilities\ICapability; | ||
use OCP\IConfig; | ||
use OCP\IUserSession; | ||
|
||
class Capabilities implements ICapability { | ||
/** @psalm-suppress PossiblyUnusedMethod */ | ||
public function __construct( | ||
private IUserSession $userSession, | ||
private IConfig $config, | ||
) { | ||
} | ||
|
||
/** | ||
* @return array{ | ||
* recommendations?: array{ | ||
* enabled: bool, | ||
* }, | ||
* } | ||
*/ | ||
public function getCapabilities(): array { | ||
$user = $this->userSession->getUser(); | ||
if ($user === null) { | ||
return []; | ||
} | ||
|
||
$enabled = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled', 'true') === 'true'; | ||
return [ | ||
'recommendations' => [ | ||
'enabled' => $enabled, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters