зеркало из https://github.com/nextcloud/spreed.git
Also delete rooms when the leaving user is the only non-guest
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
89baedc4ab
Коммит
d1237a4ba0
|
@ -167,7 +167,7 @@ class RoomController extends OCSController {
|
|||
'displayName' => $room->getName(),
|
||||
'participantType' => $participantType,
|
||||
'participantInCall' => $participantInCall,
|
||||
'count' => $room->getNumberOfParticipants(time() - 30),
|
||||
'count' => $room->getNumberOfParticipants(false, time() - 30),
|
||||
'hasPassword' => $room->hasPassword(),
|
||||
'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
|
||||
];
|
||||
|
|
10
lib/Room.php
10
lib/Room.php
|
@ -766,10 +766,11 @@ class Room {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $ignoreGuests
|
||||
* @param int $lastPing When the last ping is older than the given timestamp, the user is ignored
|
||||
* @return int
|
||||
*/
|
||||
public function getNumberOfParticipants($lastPing = 0) {
|
||||
public function getNumberOfParticipants($ignoreGuests = true, $lastPing = 0) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->selectAlias($query->createFunction('COUNT(*)'), 'num_participants')
|
||||
->from('talk_participants')
|
||||
|
@ -779,6 +780,13 @@ class Room {
|
|||
$query->andWhere($query->expr()->gt('last_ping', $query->createNamedParameter($lastPing, IQueryBuilder::PARAM_INT)));
|
||||
}
|
||||
|
||||
if ($ignoreGuests) {
|
||||
$query->andWhere($query->expr()->notIn('participant_type', $query->createNamedParameter([
|
||||
Participant::GUEST,
|
||||
Participant::USER_SELF_JOINED,
|
||||
], IQueryBuilder::PARAM_INT_ARRAY)));
|
||||
}
|
||||
|
||||
$result = $query->execute();
|
||||
$row = $result->fetch();
|
||||
$result->closeCursor();
|
||||
|
|
Загрузка…
Ссылка в новой задаче