Skip to content

Commit

Permalink
Merge pull request littleredbutton#293 from arawa/fix/288/expose_app_…
Browse files Browse the repository at this point in the history
…capabilities

fix: littleredbutton#288 expose app capabilities
  • Loading branch information
ThibautPlg authored Oct 22, 2024
2 parents b7a864c + a9082d3 commit 7233d21
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function register(IRegistrationContext $context): void {

$context->registerMiddleware(JoinMiddleware::class);
$context->registerMiddleware(HookMiddleware::class);

$context->registerCapability(Capabilities::class);
}

public function boot(IBootContext $context): void {
Expand Down
31 changes: 31 additions & 0 deletions lib/AppInfo/Capabilities.php
Original file line number Diff line number Diff line change
@@ -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)
];
}
}

0 comments on commit 7233d21

Please sign in to comment.