Browse Source
refactor: Extract generalized getter with parameter
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
pull/12604/head
Daniel Calviño Sánchez
1 year ago
committed by
Joas Schilling
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
2 changed files with
28 additions and
1 deletions
-
lib/Model/AttendeeMapper.php
-
lib/Service/ParticipantService.php
|
|
|
@ -101,6 +101,26 @@ class AttendeeMapper extends QBMapper { |
|
|
|
return $this->findEntities($query); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param int $roomId |
|
|
|
* @param array $actorTypes |
|
|
|
* @param int|null $lastJoinedCall |
|
|
|
* @return Attendee[] |
|
|
|
*/ |
|
|
|
public function getActorsByTypes(int $roomId, array $actorTypes, ?int $lastJoinedCall = null): array { |
|
|
|
$query = $this->db->getQueryBuilder(); |
|
|
|
$query->select('*') |
|
|
|
->from($this->getTableName()) |
|
|
|
->where($query->expr()->eq('room_id', $query->createNamedParameter($roomId, IQueryBuilder::PARAM_INT))) |
|
|
|
->andWhere($query->expr()->in('actor_type', $query->createNamedParameter($actorTypes, IQueryBuilder::PARAM_STR_ARRAY))); |
|
|
|
|
|
|
|
if ($lastJoinedCall !== null) { |
|
|
|
$query->andWhere($query->expr()->gte('last_joined_call', $query->createNamedParameter($lastJoinedCall, IQueryBuilder::PARAM_INT))); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->findEntities($query); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param int $roomId |
|
|
|
* @param array $participantType |
|
|
|
|
|
|
|
@ -1619,11 +1619,18 @@ class ParticipantService { |
|
|
|
* @return string[] |
|
|
|
*/ |
|
|
|
public function getParticipantUserIds(Room $room, ?\DateTime $maxLastJoined = null): array { |
|
|
|
return $this->getParticipantActorIdsByActorType($room, [Attendee::ACTOR_USERS], $maxLastJoined); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return string[] |
|
|
|
*/ |
|
|
|
public function getParticipantActorIdsByActorType(Room $room, array $actorTypes, ?\DateTime $maxLastJoined = null): array { |
|
|
|
$maxLastJoinedTimestamp = null; |
|
|
|
if ($maxLastJoined !== null) { |
|
|
|
$maxLastJoinedTimestamp = $maxLastJoined->getTimestamp(); |
|
|
|
} |
|
|
|
$attendees = $this->attendeeMapper->getActorsByType($room->getId(), Attendee::ACTOR_USERS, $maxLastJoinedTimestamp); |
|
|
|
$attendees = $this->attendeeMapper->getActorsByTypes($room->getId(), $actorTypes, $maxLastJoinedTimestamp); |
|
|
|
|
|
|
|
return array_map(static function (Attendee $attendee) { |
|
|
|
return $attendee->getActorId(); |
|
|
|
|