fix: #288 expose app capabilities

Signed-off-by: Sebastien Marinier <sebastien.marinier@arawa.fr>
pull/293/head
Sebastien Marinier 2024-10-21 17:54:44 +02:00
parent b7a864c658
commit a9082d3a46
2 changed files with 33 additions and 0 deletions

View File

@ -56,6 +56,8 @@ class Application extends App implements IBootstrap {
$context->registerMiddleware(JoinMiddleware::class);
$context->registerMiddleware(HookMiddleware::class);
$context->registerCapability(Capabilities::class);
}
public function boot(IBootContext $context): void {

View File

@ -0,0 +1,31 @@
<?php
namespace OCA\BigBlueButton\AppInfo;
use OCA\BigBlueButton\Permission;
use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\IUserSession;
class Capabilities implements ICapability {
public function __construct(private IUserSession $userSession, private IAppManager $appManager, private Permission $permission) {
}
public function getCapabilities(): array {
$user = $this->userSession->getUser();
if (!$user) {
return [];
}
$restriction = $this->permission->getRestriction($user->getUID());
$capabilities = array_filter($restriction->jsonSerialize(), function ($key) {
return in_array($key, ['maxRooms', 'maxParticipants', 'allowRecording']);
}, ARRAY_FILTER_USE_KEY);
return [
Application::ID => array_merge([
'appVersion' => $this->appManager->getAppVersion(Application::ID),
'isAllowedToCreateRoom' => $this->permission->isAllowedToCreateRoom($user->getUID()),
], $capabilities)
];
}
}