diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index a9d2589..ad2042b 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -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 { diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php new file mode 100644 index 0000000..1517557 --- /dev/null +++ b/lib/AppInfo/Capabilities.php @@ -0,0 +1,31 @@ +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) + ]; + } +}