diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index a9d2589b..ad2042b2 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -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 { diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php new file mode 100644 index 00000000..15175572 --- /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) + ]; + } +}