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:
authorJoachim Bauch <bauch@struktur.de>2020-10-30 16:33:15 +0300
committerJoas Schilling <coding@schilljs.com>2020-11-26 11:46:43 +0300
commit3f6fe4fafaacef61e680b0ccdecb8b480371f056 (patch)
tree8c2fa7b09fb00259816f7c6c0bd56d86eefb731d /lib/Manager.php
parent384b4baff1b38241de5376fdd08b0e5fffa70d9b (diff)
Add method to get room by actorId / actorType.
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Diffstat (limited to 'lib/Manager.php')
-rw-r--r--lib/Manager.php60
1 files changed, 45 insertions, 15 deletions
diff --git a/lib/Manager.php b/lib/Manager.php
index daf458550..5d883d9e0 100644
--- a/lib/Manager.php
+++ b/lib/Manager.php
@@ -467,29 +467,25 @@ class Manager {
/**
* @param string $token
- * @param string|null $preloadUserId Load this participants information if possible
+ * @param string $actorId
+ * @param string $actorType
* @return Room
* @throws RoomNotFoundException
*/
- public function getRoomByToken(string $token, ?string $preloadUserId = null): Room {
- $preloadUserId = $preloadUserId === '' ? null : $preloadUserId;
-
+ public function getRoomByActor(string $token, string $actorId, string $actorType): Room {
$query = $this->db->getQueryBuilder();
$query->select('r.*')
+ ->addSelect('a.*')
+ ->selectAlias('a.id', 'a_id')
->selectAlias('r.id', 'r_id')
->from('talk_rooms', 'r')
+ ->leftJoin('r', 'talk_attendees', 'a', $query->expr()->andX(
+ $query->expr()->eq('a.actor_id', $query->createNamedParameter($actorId)),
+ $query->expr()->eq('a.actor_type', $query->createNamedParameter($actorType)),
+ $query->expr()->eq('a.room_id', 'r.id')
+ ))
->where($query->expr()->eq('r.token', $query->createNamedParameter($token)));
- if ($preloadUserId !== null) {
- $query->addSelect('a.*')
- ->selectAlias('a.id', 'a_id');
- $query->leftJoin('r', 'talk_attendees', 'a', $query->expr()->andX(
- $query->expr()->eq('a.actor_id', $query->createNamedParameter($preloadUserId)),
- $query->expr()->eq('a.actor_type', $query->createNamedParameter(Attendee::ACTOR_USERS)),
- $query->expr()->eq('a.room_id', 'r.id')
- ));
- }
-
$result = $query->execute();
$row = $result->fetch();
$result->closeCursor();
@@ -504,7 +500,7 @@ class Manager {
}
$room = $this->createRoomObject($row);
- if ($preloadUserId !== null && isset($row['actor_id'])) {
+ if (isset($row['actor_id'])) {
$room->setParticipant($row['actor_id'], $this->createParticipantObject($room, $row));
}
@@ -512,6 +508,40 @@ class Manager {
}
/**
+ * @param string $token
+ * @param string|null $preloadUserId Load this participants information if possible
+ * @return Room
+ * @throws RoomNotFoundException
+ */
+ public function getRoomByToken(string $token, ?string $preloadUserId = null): Room {
+ $preloadUserId = $preloadUserId === '' ? null : $preloadUserId;
+ if ($preloadUserId !== null) {
+ return $this->getRoomByActor($token, $preloadUserId, Attendee::ACTOR_USERS);
+ }
+
+ $query = $this->db->getQueryBuilder();
+ $query->select('r.*')
+ ->selectAlias('r.id', 'r_id')
+ ->from('talk_rooms', 'r')
+ ->where($query->expr()->eq('r.token', $query->createNamedParameter($token)));
+
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ if ($row === false) {
+ throw new RoomNotFoundException();
+ }
+
+ if ($row['token'] === null) {
+ // FIXME Temporary solution for the Talk6 release
+ throw new RoomNotFoundException();
+ }
+
+ return $this->createRoomObject($row);
+ }
+
+ /**
* @param string $objectType
* @param string $objectId
* @return Room