mirror of https://github.com/sualko/cloud_bbb
fix: #288 expose app capabilities
Signed-off-by: Sebastien Marinier <sebastien.marinier@arawa.fr>pull/293/head
parent
b7a864c658
commit
a9082d3a46
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue