diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-30 17:08:43 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-11-26 11:46:43 +0300 |
commit | f3e6e5667f70300dcb0ef84546600ec2853b1108 (patch) | |
tree | f54f73757241a23a872e42ada9ab49ae062cf1c9 /lib/Room.php | |
parent | d0e799b4458b6c00e2f329b9878f400440c6d759 (diff) |
Get the participant by actor
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Room.php')
-rw-r--r-- | lib/Room.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Room.php b/lib/Room.php index 2061284f7..cadf60d77 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -455,6 +455,38 @@ class Room { return $this->manager->createParticipantObject($this, $row); } + /** + * @param string $actorType + * @param string $actorId + * @return Participant + * @throws ParticipantNotFoundException When the pin is not valid (has no participant assigned) + */ + public function getParticipantByActor(string $actorType, string $actorId): Participant { + if ($actorType === Attendee::ACTOR_USERS) { + return $this->getParticipant($actorId); + } + + $query = $this->db->getQueryBuilder(); + $query->select('*') + ->selectAlias('a.id', 'a_id') + ->selectAlias('s.id', 's_id') + ->from('talk_attendees', 'a') + ->leftJoin('a', 'talk_sessions', 's', $query->expr()->eq('a.id', 's.attendee_id')) + ->andWhere($query->expr()->eq('a.actor_type', $query->createNamedParameter($actorType))) + ->andWhere($query->expr()->eq('a.actor_id', $query->createNamedParameter($actorId))) + ->andWhere($query->expr()->eq('a.room_id', $query->createNamedParameter($this->getId()))) + ->setMaxResults(1); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if ($row === false) { + throw new ParticipantNotFoundException('User is not a participant'); + } + + return $this->manager->createParticipantObject($this, $row); + } + public function deleteRoom(): void { $event = new RoomEvent($this); $this->dispatcher->dispatch(self::EVENT_BEFORE_ROOM_DELETE, $event); |