diff --git a/lib/Permission.php b/lib/Permission.php index b185b99..2570f04 100644 --- a/lib/Permission.php +++ b/lib/Permission.php @@ -55,10 +55,13 @@ class Permission { } public function isAllowedToCreateRoom(string $uid): bool { - $numberOfCreatedRooms = count($this->roomService->findAll($uid, [], [])); $restriction = $this->getRestriction($uid); + if ($restriction->getMaxRooms() < 0) { + return true; + } + $numberOfCreatedRooms = count($this->roomService->findByUserId($uid)); - return $restriction->getMaxRooms() < 0 || $restriction->getMaxRooms() > $numberOfCreatedRooms; + return $restriction->getMaxRooms() > $numberOfCreatedRooms; } public function isUser(Room $room, ?string $uid): bool { diff --git a/tests/Unit/PermissionTest.php b/tests/Unit/PermissionTest.php index 09129c5..104c9e9 100644 --- a/tests/Unit/PermissionTest.php +++ b/tests/Unit/PermissionTest.php @@ -83,7 +83,8 @@ class PermissionTest extends TestCase { $this->roomService ->expects($this->once()) - ->method('findAll') + ->method('findByUserId') + ->with('foobar') ->willReturn([ $this->createRoom(1, 'foo'), $this->createRoom(2, 'bar'), diff --git a/ts/Manager/App.tsx b/ts/Manager/App.tsx index 2a6dbc4..aec8ac0 100644 --- a/ts/Manager/App.tsx +++ b/ts/Manager/App.tsx @@ -146,7 +146,8 @@ const App: React.FC = () => { } const maxRooms = restriction?.maxRooms || 0; - const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms; + const ownRoomsLength = rooms.filter(room => room.userId === OC.currentUser).length; + const quota = maxRooms < 0 ? t('bbb', 'unlimited') : ownRoomsLength + ' / ' + maxRooms; return (
= () => { {!isLoaded && } - {(maxRooms > rows.length || maxRooms < 0) ? + {(maxRooms > ownRoomsLength || maxRooms < 0) ? :

{maxRooms === 0 ? t('bbb', 'You are not permitted to create a room.') :