Reset the in-call flags when the lobby kicks in

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-02-27 16:45:33 +01:00
Родитель 91e866b33d
Коммит 1d5cf96356
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
1 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@ -620,6 +620,17 @@ class Room {
$this->dispatcher->dispatch(self::EVENT_AFTER_LOBBY_STATE_SET, $event); $this->dispatcher->dispatch(self::EVENT_AFTER_LOBBY_STATE_SET, $event);
if ($newState === Webinary::LOBBY_NON_MODERATORS) {
$participants = $this->getParticipantsInCall();
foreach ($participants as $participant) {
if ($participant->hasModeratorPermissions()) {
continue;
}
$this->changeInCall($participant, Participant::FLAG_DISCONNECTED);
}
}
return true; return true;
} }
@ -984,6 +995,27 @@ class Room {
return $participants; return $participants;
} }
/**
* @return Participant[]
*/
public function getParticipantsInCall(): array {
$query = $this->db->getQueryBuilder();
$query->select('*')
->from('talk_participants')
->where($query->expr()->eq('room_id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->neq('in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED)));
$result = $query->execute();
$participants = [];
while ($row = $result->fetch()) {
$participants[] = $this->manager->createParticipantObject($this, $row);
}
$result->closeCursor();
return $participants;
}
/** /**
* @param int $lastPing When the last ping is older than the given timestamp, the user is ignored * @param int $lastPing When the last ping is older than the given timestamp, the user is ignored
* @return array[] Array of users with [users => [userId => [lastPing, sessionId]], guests => [[lastPing, sessionId]]] * @return array[] Array of users with [users => [userId => [lastPing, sessionId]], guests => [[lastPing, sessionId]]]