From 4cec3d2ac4c51ad7ad9103b0e5b4ef569eb9812a Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 8 Apr 2024 14:24:12 -0300 Subject: [PATCH] feat: implement filter at file list Signed-off-by: Vitor Mattos --- lib/Controller/FileController.php | 4 ++-- lib/Db/SignRequestMapper.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Controller/FileController.php b/lib/Controller/FileController.php index 49198e0b71..598cbb7577 100644 --- a/lib/Controller/FileController.php +++ b/lib/Controller/FileController.php @@ -155,10 +155,10 @@ public function validate(?string $type = null, $identifier = null): JSONResponse #[NoAdminRequired] #[NoCSRFRequired] - public function list($page = null, $length = null): JSONResponse { + public function list($page = null, $length = null, ?array $filter = []): JSONResponse { $return = $this->fileService ->setMe($this->userSession->getUser()) - ->listAssociatedFilesOfSignFlow($page, $length); + ->listAssociatedFilesOfSignFlow($page, $length, $filter); return new JSONResponse($return, Http::STATUS_OK); } diff --git a/lib/Db/SignRequestMapper.php b/lib/Db/SignRequestMapper.php index 258d7cc2a5..0f8fa5492a 100644 --- a/lib/Db/SignRequestMapper.php +++ b/lib/Db/SignRequestMapper.php @@ -352,9 +352,10 @@ public function getByFileIdAndSignRequestId(int $fileId, int $signRequestId): Si public function getFilesAssociatedFilesWithMeFormatted( IUser $user, int $page = null, - int $length = null + int $length = null, + array $filter, ): array { - $pagination = $this->getFilesAssociatedFilesWithMeStmt($user->getUID(), $user->getEMailAddress()); + $pagination = $this->getFilesAssociatedFilesWithMeStmt($user->getUID(), $user->getEMailAddress(), $filter); $pagination->setMaxPerPage($length); $pagination->setCurrentPage($page); $currentPageResults = $pagination->getCurrentPageResults(); @@ -488,6 +489,11 @@ private function getFilesAssociatedFilesWithMeQueryBuilder(string $userId, ?stri } $qb->where($qb->expr()->orX(...$or)); if ($filter) { + if (isset($filter['signer_uuid'])) { + $qb->andWhere( + $qb->expr()->eq('sr.uuid', $qb->createNamedParameter($filter['signer_uuid'])) + ); + } if (isset($filter['nodeId'])) { $qb->andWhere( $qb->expr()->eq('f.node_id', $qb->createNamedParameter($filter['nodeId'], IQueryBuilder::PARAM_INT))