mirror of https://github.com/sualko/cloud_bbb
Merge pull request #296 from arawa/fix/290/max_number_of_rooms_count_only_owned_rooms
fix: #290 max number of rooms shloud take only owned rooms in accountpull/278/merge
commit
3c45a93ece
|
@ -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