diff --git a/appinfo/routes/routesPageController.php b/appinfo/routes/routesPageController.php index cf3f09bd0a..cd50379d94 100644 --- a/appinfo/routes/routesPageController.php +++ b/appinfo/routes/routesPageController.php @@ -10,7 +10,7 @@ ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'page#indexF', 'url' => '/f/', 'verb' => 'GET'], ['name' => 'page#indexFPath', 'url' => '/f/{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], 'postfix' => 'front'], - ['name' => 'page#getPdfAccountFile', 'url' => '/pdf/user/{uuid}', 'verb' => 'GET'], + ['name' => 'page#getPdfFile', 'url' => '/pdf/{uuid}', 'verb' => 'GET'], ['name' => 'page#resetPassword', 'url' => '/reset-password', 'verb' => 'GET'], // Pages - public ['name' => 'page#sign', 'url' => '/p/sign/{uuid}', 'verb' => 'GET'], diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 441763d97f..19fb87a5a8 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -108,7 +108,7 @@ public function createToSign(string $uuid, string $email, string $password, ?str 'message' => $this->l10n->t('Success'), 'action' => JSActions::ACTION_SIGN, 'pdf' => [ - 'url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $uuid]) + 'url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $uuid]) ], 'filename' => $fileToSign['fileData']->getName(), 'description' => $signRequest->getDescription() diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index a0a1c3b117..4f20bd81d8 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -287,7 +287,7 @@ public function getPdf($uuid) { #[PublicPage] #[RequireSetupOk] #[AnonRateLimit(limit: 30, period: 60)] - public function getPdfAccountFile($uuid) { + public function getPdfFile($uuid) { $this->throwIfValidationPageNotAccessible(); $resp = new FileDisplayResponse($this->getNextcloudFile()); $resp->addHeader('Content-Type', 'application/pdf'); diff --git a/lib/Db/AccountFileMapper.php b/lib/Db/AccountFileMapper.php index 288137ba4f..9774836b96 100644 --- a/lib/Db/AccountFileMapper.php +++ b/lib/Db/AccountFileMapper.php @@ -97,7 +97,7 @@ public function accountFileList(array $filter, int $page = null, int $length = n $pagination->setCurrentPage($page); $currentPageResults = $pagination->getCurrentPageResults(); - $url = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => '_replace_']); + $url = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => '_replace_']); $url = str_replace('_replace_', '', $url); $data = []; diff --git a/lib/Db/SignRequestMapper.php b/lib/Db/SignRequestMapper.php index 04527a4ded..bbb2cf9ed2 100644 --- a/lib/Db/SignRequestMapper.php +++ b/lib/Db/SignRequestMapper.php @@ -545,6 +545,7 @@ private function associateAllAndFormat(IUser $user, array $files, array $signers if ($data['me']) { $data['sign_uuid'] = $signer->getUuid(); + $data['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signer->getuuid()]); } if ($signer->getSigned()) { @@ -583,7 +584,6 @@ private function formatListRow(array $row): array { ->setTimestamp((int) $row['request_date']) ->format('Y-m-d H:i:s'); $row['file'] = $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $row['uuid']]); - $row['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $row['uuid']]); $row['nodeId'] = (int) $row['node_id']; $row['uuid'] = $row['uuid']; unset( diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 25af403cda..675fac269d 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -177,7 +177,7 @@ public function setFileByType(string $type, $identifier): self { } private function getSigners(): array { - if (!$this->file) { + if ($this->signers) { return $this->signers; } $signers = $this->signRequestMapper->getByFileId($this->file->getId()); @@ -382,7 +382,12 @@ private function getFile(): array { 'displayName' => $this->userManager->get($this->file->getUserId())->getDisplayName(), ]; $return['file'] = $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $this->file->getUuid()]); - $return['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $this->file->getUuid()]); + foreach ($this->getSigners() as $signer) { + if ($signer['me']) { + $return['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signer['sign_uuid']]); + break; + } + } if ($this->showSigners) { $return['signers'] = $this->getSigners(); } diff --git a/lib/Service/SignFileService.php b/lib/Service/SignFileService.php index ed3da657cc..a12b27d5a6 100644 --- a/lib/Service/SignFileService.php +++ b/lib/Service/SignFileService.php @@ -683,7 +683,7 @@ public function getFileUrl(string $format, FileEntity $fileEntity, File $fileToS $this->accountFileMapper->getByFileId($fileEntity->getId()); $url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $uuid])]; } catch (DoesNotExistException $e) { - $url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $uuid])]; + $url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $uuid])]; } break; case 'nodeId':