diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 642f2e701c5..bcad873c0f7 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -382,12 +382,11 @@ protected function getUsersInRoom(Room $room, int $pingTimestamp): array { $timestamp = min($this->timeFactory->getTime() - (self::PULL_MESSAGES_TIMEOUT + 10), $pingTimestamp); // "- 1" is needed because only the participants whose last ping is // greater than the given timestamp are returned. - // FIXME needs to select session and left join attendees instead! - $participants = $this->participantService->getParticipantsForRoom($room); + $participants = $this->participantService->getParticipantsForAllSessions($room, $timestamp - 1); foreach ($participants as $participant) { $session = $participant->getSession(); if (!$session instanceof Session) { - // User is not active + // This is just to make Psalm happy, since we select by session it's always with one. continue; } diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index e4b5729f625..a788d009ca2 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -604,9 +604,10 @@ public function getParticipantsForRoom(Room $room): array { /** * @param Room $room + * @param int $maxAge * @return Participant[] */ - public function getParticipantsForAllSessions(Room $room): array { + public function getParticipantsForAllSessions(Room $room, int $maxAge = 0): array { $query = $this->connection->getQueryBuilder(); $helper = new SelectHelper(); @@ -620,6 +621,10 @@ public function getParticipantsForAllSessions(Room $room): array { ->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->isNotNull('s.id')); + if ($maxAge > 0) { + $query->andWhere($query->expr()->gt('s.last_ping', $query->createNamedParameter($maxAge, IQueryBuilder::PARAM_INT))); + } + return $this->getParticipantsFromQuery($query, $room); } diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index fb290f0438e..2b524505aa7 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -251,8 +251,7 @@ public function participantsModified(Room $room, array $sessionIds): void { $this->logger->info('Room participants modified: ' . $room->getToken() . ' ' . print_r($sessionIds, true)); $changed = []; $users = []; - // FIXME needs to select session and left join attendees instead! - $participants = $this->participantService->getParticipantsForRoom($room); + $participants = $this->participantService->getParticipantsForAllSessions($room); foreach ($participants as $participant) { $attendee = $participant->getAttendee(); if ($attendee->getActorType() !== Attendee::ACTOR_USERS @@ -312,8 +311,7 @@ public function roomInCallChanged(Room $room, int $flags, array $sessionIds): vo $changed = []; $users = []; - // FIXME needs to select session and left join attendees instead! - $participants = $this->participantService->getParticipantsForRoom($room); + $participants = $this->participantService->getParticipantsForAllSessions($room); foreach ($participants as $participant) { $attendee = $participant->getAttendee(); if ($attendee->getActorType() !== Attendee::ACTOR_USERS