diff --git a/lib/OCP/TalkBackend.php b/lib/OCP/TalkBackend.php index 35498b6a07d..a09e543f193 100644 --- a/lib/OCP/TalkBackend.php +++ b/lib/OCP/TalkBackend.php @@ -9,6 +9,7 @@ namespace OCA\Talk\OCP; +use OCA\Talk\Config; use OCA\Talk\Manager; use OCA\Talk\Model\Attendee; use OCA\Talk\Participant; @@ -16,6 +17,7 @@ use OCA\Talk\Service\ParticipantService; use OCA\Talk\Service\RoomService; use OCP\IURLGenerator; +use OCP\IUserSession; use OCP\Talk\IConversation; use OCP\Talk\IConversationOptions; use OCP\Talk\ITalkBackend; @@ -27,6 +29,8 @@ public function __construct( protected ParticipantService $participantService, protected RoomService $roomService, protected IURLGenerator $url, + protected IUserSession $userSession, + protected Config $config, ) { } @@ -68,4 +72,21 @@ public function deleteConversation(string $id): void { $room = $this->manager->getRoomByToken($id); $this->roomService->deleteRoom($room); } + + public function isAllowedToCreateConversations(): bool { + $user = $this->userSession->getUser(); + if ($user === null) { + return false; + } + + return !$this->config->isNotAllowedToCreateConversations($user); + } + + public function isEnabledForUser(): bool { + $user = $this->userSession->getUser(); + if ($user === null) { + return false; + } + return !$this->config->isDisabledForUser($user); + } } diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 7036a081c27..e73d12b0436 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -1,5 +1,5 @@ - + @@ -150,6 +150,12 @@ rooms]]> + + + + + +