mirror of https://github.com/sualko/cloud_bbb
feat: list all shared rooms for users and moderators
parent
5935c093dd
commit
0219cf5df0
|
@ -74,6 +74,7 @@ class Room extends Entity implements JsonSerializable {
|
||||||
public $cleanLayout;
|
public $cleanLayout;
|
||||||
public $joinMuted;
|
public $joinMuted;
|
||||||
public $running;
|
public $running;
|
||||||
|
public $permission;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addType('maxParticipants', 'integer');
|
$this->addType('maxParticipants', 'integer');
|
||||||
|
@ -86,6 +87,7 @@ class Room extends Entity implements JsonSerializable {
|
||||||
$this->addType('cleanLayout', 'boolean');
|
$this->addType('cleanLayout', 'boolean');
|
||||||
$this->addType('joinMuted', 'boolean');
|
$this->addType('joinMuted', 'boolean');
|
||||||
$this->addType('running', 'boolean');
|
$this->addType('running', 'boolean');
|
||||||
|
$this->addType('permission', 'integer');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize(): array {
|
public function jsonSerialize(): array {
|
||||||
|
@ -102,6 +104,7 @@ class Room extends Entity implements JsonSerializable {
|
||||||
'everyoneIsModerator' => boolval($this->everyoneIsModerator),
|
'everyoneIsModerator' => boolval($this->everyoneIsModerator),
|
||||||
'requireModerator' => boolval($this->requireModerator),
|
'requireModerator' => boolval($this->requireModerator),
|
||||||
'shared' => boolval($this->shared),
|
'shared' => boolval($this->shared),
|
||||||
|
'permission' => $this->permission,
|
||||||
'moderatorToken' => $this->moderatorToken,
|
'moderatorToken' => $this->moderatorToken,
|
||||||
'listenOnly' => boolval($this->listenOnly),
|
'listenOnly' => boolval($this->listenOnly),
|
||||||
'mediaCheck' => boolval($this->mediaCheck),
|
'mediaCheck' => boolval($this->mediaCheck),
|
||||||
|
|
|
@ -12,6 +12,16 @@ class RoomMapper extends QBMapper {
|
||||||
parent::__construct($db, 'bbb_rooms', Room::class);
|
parent::__construct($db, 'bbb_rooms', Room::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function joinShares(IQueryBuilder $qb): IQueryBuilder {
|
||||||
|
$qb->select('r.*')
|
||||||
|
->from($this->tableName, 'r')
|
||||||
|
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
|
||||||
|
->addSelect($qb->createFunction('count(case when `s`.`permission` IN ('.
|
||||||
|
RoomShare::PERMISSION_ADMIN.','.RoomShare::PERMISSION_MODERATOR.','.RoomShare::PERMISSION_USER
|
||||||
|
.') then 1 else null end) as shared'));
|
||||||
|
return $qb;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
* @throws DoesNotExistException
|
* @throws DoesNotExistException
|
||||||
|
@ -19,10 +29,7 @@ class RoomMapper extends QBMapper {
|
||||||
public function find(int $id): Room {
|
public function find(int $id): Room {
|
||||||
/* @var $qb IQueryBuilder */
|
/* @var $qb IQueryBuilder */
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('r.*')
|
$this->joinShares($qb)
|
||||||
->from($this->tableName, 'r')
|
|
||||||
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
|
|
||||||
->addSelect($qb->createFunction('count(case when `s`.`permission` = 0 then 1 else null end) as shared'))
|
|
||||||
->where($qb->expr()->eq('r.id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
|
->where($qb->expr()->eq('r.id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
|
||||||
->groupBy('r.id');
|
->groupBy('r.id');
|
||||||
;
|
;
|
||||||
|
@ -38,10 +45,7 @@ class RoomMapper extends QBMapper {
|
||||||
public function findByUid(string $uid): Room {
|
public function findByUid(string $uid): Room {
|
||||||
/* @var $qb IQueryBuilder */
|
/* @var $qb IQueryBuilder */
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('r.*')
|
$this->joinShares($qb)
|
||||||
->from($this->tableName, 'r')
|
|
||||||
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
|
|
||||||
->addSelect($qb->createFunction('count(case when `s`.`permission` = 0 then 1 else null end) as shared'))
|
|
||||||
->where($qb->expr()->eq('r.uid', $qb->createNamedParameter($uid)))
|
->where($qb->expr()->eq('r.uid', $qb->createNamedParameter($uid)))
|
||||||
->groupBy('r.id');
|
->groupBy('r.id');
|
||||||
;
|
;
|
||||||
|
@ -70,25 +74,20 @@ class RoomMapper extends QBMapper {
|
||||||
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
||||||
/* @var $qb IQueryBuilder */
|
/* @var $qb IQueryBuilder */
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('r.*')
|
$this->joinShares($qb)
|
||||||
->from($this->tableName, 'r')
|
->addSelect($qb->createFunction('min(case when `r`.`user_id` ='. $qb->createNamedParameter($userId).' then '.RoomShare::PERMISSION_ADMIN.' else `s`.`permission` end) as permission'))
|
||||||
->leftJoin('r', 'bbb_room_shares', 's', $qb->expr()->eq('r.id', 's.room_id'))
|
|
||||||
->addSelect($qb->createFunction('count(case when `s`.`permission` = 0 then 1 else null end) as shared'))
|
|
||||||
->where(
|
->where(
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->eq('r.user_id', $qb->createNamedParameter($userId)),
|
$qb->expr()->eq('r.user_id', $qb->createNamedParameter($userId)),
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->eq('s.permission', $qb->createNamedParameter(RoomShare::PERMISSION_ADMIN, IQueryBuilder::PARAM_INT)),
|
|
||||||
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_USER, IQueryBuilder::PARAM_INT)),
|
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_USER, IQueryBuilder::PARAM_INT)),
|
||||||
$qb->expr()->eq('s.share_with', $qb->createNamedParameter($userId))
|
$qb->expr()->eq('s.share_with', $qb->createNamedParameter($userId))
|
||||||
),
|
),
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->eq('s.permission', $qb->createNamedParameter(RoomShare::PERMISSION_ADMIN, IQueryBuilder::PARAM_INT)),
|
|
||||||
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_GROUP, IQueryBuilder::PARAM_INT)),
|
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_GROUP, IQueryBuilder::PARAM_INT)),
|
||||||
$qb->expr()->in('s.share_with', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY))
|
$qb->expr()->in('s.share_with', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY))
|
||||||
),
|
),
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->eq('s.permission', $qb->createNamedParameter(RoomShare::PERMISSION_ADMIN, IQueryBuilder::PARAM_INT)),
|
|
||||||
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)),
|
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)),
|
||||||
$qb->expr()->in('s.share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY))
|
$qb->expr()->in('s.share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY))
|
||||||
)
|
)
|
||||||
|
@ -99,7 +98,7 @@ class RoomMapper extends QBMapper {
|
||||||
/** @var array<Room> */
|
/** @var array<Room> */
|
||||||
return $this->findEntities($qb);
|
return $this->findEntities($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<Room>
|
* @return array<Room>
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue