mirror of https://github.com/sualko/cloud_bbb
fix: #290 max number of rooms shloud take only owned rooms in account
Signed-off-by: Sebastien Marinier <sebastien.marinier@arawa.fr>pull/296/head
parent
7233d21a85
commit
79518b9bac
|
@ -55,10 +55,13 @@ class Permission {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAllowedToCreateRoom(string $uid): bool {
|
public function isAllowedToCreateRoom(string $uid): bool {
|
||||||
$numberOfCreatedRooms = count($this->roomService->findAll($uid, [], []));
|
|
||||||
$restriction = $this->getRestriction($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 {
|
public function isUser(Room $room, ?string $uid): bool {
|
||||||
|
|
|
@ -83,7 +83,8 @@ class PermissionTest extends TestCase {
|
||||||
|
|
||||||
$this->roomService
|
$this->roomService
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('findAll')
|
->method('findByUserId')
|
||||||
|
->with('foobar')
|
||||||
->willReturn([
|
->willReturn([
|
||||||
$this->createRoom(1, 'foo'),
|
$this->createRoom(1, 'foo'),
|
||||||
$this->createRoom(2, 'bar'),
|
$this->createRoom(2, 'bar'),
|
||||||
|
|
|
@ -146,7 +146,8 @@ const App: React.FC<Props> = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxRooms = restriction?.maxRooms || 0;
|
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 (
|
return (
|
||||||
<div id="bbb-react-root"
|
<div id="bbb-react-root"
|
||||||
|
@ -188,7 +189,7 @@ const App: React.FC<Props> = () => {
|
||||||
{!isLoaded && <span className="icon icon-loading-small icon-visible"></span>}
|
{!isLoaded && <span className="icon icon-loading-small icon-visible"></span>}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{(maxRooms > rows.length || maxRooms < 0) ?
|
{(maxRooms > ownRoomsLength || maxRooms < 0) ?
|
||||||
<NewRoomForm addRoom={addRoom} /> :
|
<NewRoomForm addRoom={addRoom} /> :
|
||||||
<p className="text-muted">{maxRooms === 0 ?
|
<p className="text-muted">{maxRooms === 0 ?
|
||||||
t('bbb', 'You are not permitted to create a room.') :
|
t('bbb', 'You are not permitted to create a room.') :
|
||||||
|
|
Loading…
Reference in New Issue