Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make the method loop over the sessions instead of the attendees
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Feb 24, 2021
commit 9cc02f5b70f5001c2a5a5d14fbb6c5f4bbbc5ec8
11 changes: 8 additions & 3 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,22 +603,27 @@ public function getParticipantsForRoom(Room $room): array {

/**
* @param Room $room
* @param int $maxAge
* @return Participant[]
*/
public function getParticipantsWithSession(Room $room): array {
public function getParticipantsForAllSessions(Room $room, int $maxAge = 0): array {
$query = $this->connection->getQueryBuilder();

$helper = new SelectHelper();
$helper->selectAttendeesTable($query);
$helper->selectSessionsTable($query);
$query->from('talk_attendees', 'a')
$query->from('talk_sessions', 's')
->leftJoin(
'a', 'talk_sessions', 's',
's', 'talk_attendees', 'a',
$query->expr()->eq('s.attendee_id', 'a.id')
)
->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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Signaling/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function addMessageForAllParticipants(Room $room, string $message): void
]
);

$participants = $this->participantService->getParticipantsWithSession($room);
$participants = $this->participantService->getParticipantsForAllSessions($room);
foreach ($participants as $participant) {
$session = $participant->getSession();
if ($session instanceof Session) {
Expand Down