Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-10-26 17:55:48 +0300
committerJoas Schilling <coding@schilljs.com>2020-10-30 12:38:51 +0300
commit5577de7a52efc3b7d3acbedc801547034758e078 (patch)
tree0e5259c87a6659ccf8e731e3d1f345b4f0b20448 /lib/Service
parenta11b907435fdc844a207589d8f8a4cb1583453a5 (diff)
Simplify query methods and inject the config on the method
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/ParticipantService.php78
1 files changed, 19 insertions, 59 deletions
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index ae3580d85..6b6bb42c5 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -138,10 +138,7 @@ class ParticipantService {
$this->dispatcher->dispatch(Room::EVENT_AFTER_ROOM_CONNECT, $event);
- return new Participant(
- \OC::$server->getDatabaseConnection(), // FIXME
- \OC::$server->getConfig(), // FIXME
- $room, $attendee, $session);
+ return new Participant($room, $attendee, $session);
}
/**
@@ -187,10 +184,7 @@ class ParticipantService {
$this->dispatcher->dispatch(Room::EVENT_AFTER_GUEST_CONNECT, $event);
- return new Participant(
- \OC::$server->getDatabaseConnection(), // FIXME
- \OC::$server->getConfig(), // FIXME
- $room, $attendee, $session);
+ return new Participant($room, $attendee, $session);
}
/**
@@ -396,24 +390,7 @@ class ParticipantService {
)
->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)));
- $participants = [];
- $result = $query->execute();
- while ($row = $result->fetch()) {
- $attendee = $this->attendeeMapper->createAttendeeFromRow($row);
- if (isset($row['s_id'])) {
- $session = $this->sessionMapper->createSessionFromRow($row);
- } else {
- $session = null;
- }
-
- $participants[] = new Participant(
- \OC::$server->getDatabaseConnection(), // FIXME
- \OC::$server->getConfig(), // FIXME
- $room, $attendee, $session);
- }
- $result->closeCursor();
-
- return $participants;
+ return $this->getParticipantsFromQuery($query, $room);
}
/**
@@ -435,20 +412,7 @@ class ParticipantService {
->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->isNotNull('s.id'));
- $participants = [];
- $result = $query->execute();
- while ($row = $result->fetch()) {
- $attendee = $this->attendeeMapper->createAttendeeFromRow($row);
- $session = $this->sessionMapper->createSessionFromRow($row);
-
- $participants[] = new Participant(
- \OC::$server->getDatabaseConnection(), // FIXME
- \OC::$server->getConfig(), // FIXME
- $room, $attendee, $session);
- }
- $result->closeCursor();
-
- return $participants;
+ return $this->getParticipantsFromQuery($query, $room);
}
/**
@@ -470,20 +434,7 @@ class ParticipantService {
->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->neq('s.in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED)));
- $participants = [];
- $result = $query->execute();
- while ($row = $result->fetch()) {
- $attendee = $this->attendeeMapper->createAttendeeFromRow($row);
- $session = $this->sessionMapper->createSessionFromRow($row);
-
- $participants[] = new Participant(
- \OC::$server->getDatabaseConnection(), // FIXME
- \OC::$server->getConfig(), // FIXME
- $room, $attendee, $session);
- }
- $result->closeCursor();
-
- return $participants;
+ return $this->getParticipantsFromQuery($query, $room);
}
/**
@@ -506,16 +457,25 @@ class ParticipantService {
->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->eq('notification_level', $query->createNamedParameter($notificationLevel, IQueryBuilder::PARAM_INT)));
+ return $this->getParticipantsFromQuery($query, $room);
+ }
+
+ /**
+ * @param IQueryBuilder $query
+ * @return Participant[]
+ */
+ protected function getParticipantsFromQuery(IQueryBuilder $query, Room $room): array {
$participants = [];
$result = $query->execute();
while ($row = $result->fetch()) {
$attendee = $this->attendeeMapper->createAttendeeFromRow($row);
- $session = $this->sessionMapper->createSessionFromRow($row);
+ if (isset($row['s_id'])) {
+ $session = $this->sessionMapper->createSessionFromRow($row);
+ } else {
+ $session = null;
+ }
- $participants[] = new Participant(
- \OC::$server->getDatabaseConnection(), // FIXME
- \OC::$server->getConfig(), // FIXME
- $room, $attendee, $session);
+ $participants[] = new Participant($room, $attendee, $session);
}
$result->closeCursor();