fix: delete only owned rooms from deleted user

fix #131
pull/149/head
sualko 2021-04-18 19:30:44 +02:00
parent 0c3636da37
commit 4115990bb1
3 changed files with 22 additions and 1 deletions

View File

@ -50,6 +50,20 @@ class RoomMapper extends QBMapper {
return $this->findEntity($qb);
}
/**
* @return array<Room>
*/
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<Room> */
return $this->findEntities($qb);
}
/**
* @return array<Room>
*/

View File

@ -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);

View File

@ -66,6 +66,13 @@ class RoomService {
}
}
/**
* @return array<Room>
*/
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();