@@ -732,6 +732,57 @@ public function getRoomByActor(string $token, string $actorType, string $actorId
732732 return $ room ;
733733 }
734734
735+ /**
736+ * @param string $token
737+ * @param string $actorType
738+ * @param string $actorId
739+ * @param string $remoteAccess
740+ * @return Room
741+ * @throws RoomNotFoundException
742+ */
743+ public function getRoomByRemoteAccess (string $ token , string $ actorType , string $ actorId , string $ remoteAccess ): Room {
744+ $ query = $ this ->db ->getQueryBuilder ();
745+ $ helper = new SelectHelper ();
746+ $ helper ->selectRoomsTable ($ query );
747+ $ helper ->selectAttendeesTable ($ query );
748+ $ query ->from ('talk_rooms ' , 'r ' )
749+ ->leftJoin ('r ' , 'talk_attendees ' , 'a ' , $ query ->expr ()->andX (
750+ $ query ->expr ()->eq ('a.actor_type ' , $ query ->createNamedParameter ($ actorType )),
751+ $ query ->expr ()->eq ('a.actor_id ' , $ query ->createNamedParameter ($ actorId )),
752+ $ query ->expr ()->eq ('a.access_token ' , $ query ->createNamedParameter ($ remoteAccess )),
753+ $ query ->expr ()->eq ('a.room_id ' , 'r.id ' )
754+ ))
755+ ->where ($ query ->expr ()->eq ('r.token ' , $ query ->createNamedParameter ($ token )));
756+
757+ // if ($sessionId !== null) {
758+ // $helper->selectSessionsTable($query);
759+ // $query->leftJoin('a', 'talk_sessions', 's', $query->expr()->andX(
760+ // $query->expr()->eq('s.session_id', $query->createNamedParameter($sessionId)),
761+ // $query->expr()->eq('a.id', 's.attendee_id')
762+ // ));
763+ // }
764+
765+ $ result = $ query ->executeQuery ();
766+ $ row = $ result ->fetch ();
767+ $ result ->closeCursor ();
768+
769+ if ($ row === false ) {
770+ throw new RoomNotFoundException ();
771+ }
772+
773+ if ($ row ['token ' ] === null ) {
774+ // FIXME Temporary solution for the Talk6 release
775+ throw new RoomNotFoundException ();
776+ }
777+
778+ $ room = $ this ->createRoomObject ($ row );
779+ if ($ actorType === Attendee::ACTOR_FEDERATED_USERS && isset ($ row ['actor_id ' ])) {
780+ $ room ->setParticipant ($ row ['actor_id ' ], $ this ->createParticipantObject ($ room , $ row ));
781+ }
782+
783+ return $ room ;
784+ }
785+
735786 /**
736787 * @param string $token
737788 * @param string|null $preloadUserId Load this participant's information if possible
0 commit comments