diff --git a/lib/Db/RoomMapper.php b/lib/Db/RoomMapper.php index 49948bc..cd9e6d5 100644 --- a/lib/Db/RoomMapper.php +++ b/lib/Db/RoomMapper.php @@ -50,6 +50,20 @@ class RoomMapper extends QBMapper { return $this->findEntity($qb); } + /** + * @return array + */ + public function findByUserId(string $userId): array { + /* @var $qb IQueryBuilder */ + $qb = $this->db->getQueryBuilder(); + $qb->select('*') + ->from($this->tableName, 'r') + ->where($qb->expr()->eq('r.user_id', $qb->createNamedParameter($userId))); + + /** @var array */ + return $this->findEntities($qb); + } + /** * @return array */ diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php index 3825b60..0f77c9c 100644 --- a/lib/Listener/UserDeletedListener.php +++ b/lib/Listener/UserDeletedListener.php @@ -35,7 +35,7 @@ class UserDeletedListener implements IEventListener { } $userId = $event->getUser()->getUID(); - $rooms = $this->roomService->findAll($userId, [], []); + $rooms = $this->roomService->findByUserId($userId); $this->deleteSharesByUserId($userId); diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index 77f60c4..f99e14e 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -66,6 +66,13 @@ class RoomService { } } + /** + * @return array + */ + public function findByUserId(string $userId): array { + return $this->mapper->findByUserId($userId); + } + public function create(string $name, string $welcome, int $maxParticipants, bool $record, string $access, string $userId): \OCP\AppFramework\Db\Entity { $room = new Room();