From e3ad25951aa0e13045f1846469833d4debaf118e Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:28:17 -0300 Subject: [PATCH 1/6] feat: add getLabel method to SignRequestStatus enum Add a getLabel() method to the SignRequestStatus enum to provide localized status labels (Draft, Pending, Signed). This follows the same pattern as DocMdpLevel enum and centralizes the translation logic in the enum itself rather than spreading it across multiple files. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Enum/SignRequestStatus.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Enum/SignRequestStatus.php b/lib/Enum/SignRequestStatus.php index 7767179b6..1470e4ab3 100644 --- a/lib/Enum/SignRequestStatus.php +++ b/lib/Enum/SignRequestStatus.php @@ -9,8 +9,21 @@ declare(strict_types=1); namespace OCA\Libresign\Enum; +use OCP\IL10N; + enum SignRequestStatus: int { case DRAFT = 0; case ABLE_TO_SIGN = 1; case SIGNED = 2; + + public function getLabel(IL10N $l10n): string { + return match($this) { + // TRANSLATORS Name of the status when signer document is in draft state + self::DRAFT => $l10n->t('Draft'), + // TRANSLATORS Name of the status when signer can sign the document + self::ABLE_TO_SIGN => $l10n->t('Pending'), + // TRANSLATORS Name of the status when signer has already signed + self::SIGNED => $l10n->t('Signed'), + }; + } } From c5c2ee1c95621eaf61292c47b4432d02bec206e1 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:34:13 -0300 Subject: [PATCH 2/6] feat: add getTextOfSignerStatus method to SignRequestMapper Add a helper method to get localized status text for signers using the SignRequestStatus enum. This method delegates to the enum's getLabel() method to maintain consistency across the application. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Db/SignRequestMapper.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Db/SignRequestMapper.php b/lib/Db/SignRequestMapper.php index e3e4d734a..8cd9d7eb3 100644 --- a/lib/Db/SignRequestMapper.php +++ b/lib/Db/SignRequestMapper.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OCA\Libresign\Db; use DateTimeInterface; +use OCA\Libresign\Enum\SignRequestStatus; use OCA\Libresign\Helper\Pagination; use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod; use OCA\Libresign\Service\IdentifyMethodService; @@ -640,4 +641,8 @@ class SignRequestMapper extends QBMapper { $result = preg_replace($extensionPattern, '', $name); return $result ?? $name; } + + public function getTextOfSignerStatus(int $status): string { + return SignRequestStatus::from($status)->getLabel($this->l10n); + } } From 8602edfb4e7ceec89215a1c9b4fd822b51bb7b4a Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:34:26 -0300 Subject: [PATCH 3/6] feat: add status and statusText to LibresignSigner type Update the LibresignSigner psalm type definition to include status and statusText as required fields (not optional). These fields will always be present in API responses for signer data. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/ResponseDefinitions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 8fe6a468e..b712ad041 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -173,6 +173,8 @@ namespace OCA\Libresign; * hash_algorithm?: string, * me: bool, * signRequestId: non-negative-int, + * status: 0|1|2, + * statusText: string, * signingOrder?: non-negative-int, * identifyMethods?: LibresignIdentifyMethod[], * visibleElements?: LibresignVisibleElement[], From 8af983763d8f9e7bf7d122cde5e9681b2ad17a54 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:34:36 -0300 Subject: [PATCH 4/6] feat: include status and statusText in signer responses Add status and statusText fields to all signer data returned by FileService. This includes: - Signers from LibreSign metadata (loadLibreSignSigners) - Signers from PDF certificate data (loadSignersFromCertData) - Signers in file listings (associateAllAndFormat) The status field contains the numeric code (0=Draft, 1=Pending, 2=Signed) and statusText contains the localized label. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Service/FileService.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 3567ea4ea..0a7562c3b 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -387,6 +387,8 @@ class FileService { $this->fileData->signers[$index]['me'] = false; $this->fileData->signers[$index]['signRequestId'] = $signer->getId(); $this->fileData->signers[$index]['description'] = $signer->getDescription(); + $this->fileData->signers[$index]['status'] = $signer->getStatus(); + $this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()); $this->fileData->signers[$index]['signingOrder'] = $signer->getSigningOrder(); $this->fileData->signers[$index]['visibleElements'] = $this->getVisibleElements($signer->getId()); $this->fileData->signers[$index]['request_sign_date'] = $signer->getCreatedAt()->format(DateTimeInterface::ATOM); @@ -487,6 +489,11 @@ class FileService { private function loadSignersFromCertData(): void { $this->loadCertDataFromLibreSignFile(); foreach ($this->certData as $index => $signer) { + // Always set status and statusText for signers from certificate data + // These are already signed (status 2) + $this->fileData->signers[$index]['status'] = 2; + $this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus(2); + if (isset($signer['timestamp'])) { $this->fileData->signers[$index]['timestamp'] = $signer['timestamp']; if (isset($signer['timestamp']['genTime']) && $signer['timestamp']['genTime'] instanceof DateTimeInterface) { @@ -834,9 +841,10 @@ class FileService { 'request_sign_date' => $signer->getCreatedAt()->format(DateTimeInterface::ATOM), 'signed' => null, 'signRequestId' => $signer->getId(), - 'signingOrder' => $signer->getSigningOrder(), - 'status' => $signer->getStatus(), - 'me' => array_reduce($identifyMethodsOfSigner, function (bool $carry, IdentifyMethod $identifyMethod) use ($user): bool { + 'signingOrder' => $signer->getSigningOrder(), + 'status' => $signer->getStatus(), + 'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()), + 'me' => array_reduce($identifyMethodsOfSigner, function (bool $carry, IdentifyMethod $identifyMethod) use ($user): bool { if ($identifyMethod->getIdentifierKey() === IdentifyMethodService::IDENTIFY_ACCOUNT) { if ($user->getUID() === $identifyMethod->getIdentifierValue()) { return true; From ff3a16f223c28e61576d2729d05823ebe96de62c Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:34:45 -0300 Subject: [PATCH 5/6] feat: add status and statusText to ID docs signer data Include status and statusText fields when formatting signers in ID documents responses. This ensures consistency across all API endpoints that return signer information. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Db/IdDocsMapper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Db/IdDocsMapper.php b/lib/Db/IdDocsMapper.php index 76e58cdfb..6a93c77d4 100644 --- a/lib/Db/IdDocsMapper.php +++ b/lib/Db/IdDocsMapper.php @@ -283,6 +283,8 @@ class IdDocsMapper extends QBMapper { ->format('Y-m-d H:i:s'), 'sign_date' => null, 'signRequestId' => $signer->getId(), + 'status' => $signer->getStatus(), + 'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()), ]; if ($signer->getSigned()) { $data['sign_date'] = (new \DateTime()) From 80136aafd9024aa11b449037d4ef1eebb8cc1c55 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:35:14 -0300 Subject: [PATCH 6/6] chore: update openapi documentation Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Service/FileService.php | 12 +++++------- openapi-full.json | 16 +++++++++++++++- openapi.json | 16 +++++++++++++++- src/types/openapi/openapi-full.ts | 6 ++++++ src/types/openapi/openapi.ts | 6 ++++++ 5 files changed, 47 insertions(+), 9 deletions(-) diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 0a7562c3b..1aafd9ff8 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -489,11 +489,9 @@ class FileService { private function loadSignersFromCertData(): void { $this->loadCertDataFromLibreSignFile(); foreach ($this->certData as $index => $signer) { - // Always set status and statusText for signers from certificate data - // These are already signed (status 2) $this->fileData->signers[$index]['status'] = 2; $this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus(2); - + if (isset($signer['timestamp'])) { $this->fileData->signers[$index]['timestamp'] = $signer['timestamp']; if (isset($signer['timestamp']['genTime']) && $signer['timestamp']['genTime'] instanceof DateTimeInterface) { @@ -841,10 +839,10 @@ class FileService { 'request_sign_date' => $signer->getCreatedAt()->format(DateTimeInterface::ATOM), 'signed' => null, 'signRequestId' => $signer->getId(), - 'signingOrder' => $signer->getSigningOrder(), - 'status' => $signer->getStatus(), - 'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()), - 'me' => array_reduce($identifyMethodsOfSigner, function (bool $carry, IdentifyMethod $identifyMethod) use ($user): bool { + 'signingOrder' => $signer->getSigningOrder(), + 'status' => $signer->getStatus(), + 'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()), + 'me' => array_reduce($identifyMethodsOfSigner, function (bool $carry, IdentifyMethod $identifyMethod) use ($user): bool { if ($identifyMethod->getIdentifierKey() === IdentifyMethodService::IDENTIFY_ACCOUNT) { if ($user->getUID() === $identifyMethod->getIdentifierValue()) { return true; diff --git a/openapi-full.json b/openapi-full.json index 2dfd0dd25..b4eb7cf6e 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -852,7 +852,9 @@ "request_sign_date", "signed", "me", - "signRequestId" + "signRequestId", + "status", + "statusText" ], "properties": { "description": { @@ -918,6 +920,18 @@ "format": "int64", "minimum": 0 }, + "status": { + "type": "integer", + "format": "int64", + "enum": [ + 0, + 1, + 2 + ] + }, + "statusText": { + "type": "string" + }, "signingOrder": { "type": "integer", "format": "int64", diff --git a/openapi.json b/openapi.json index 7aa0a0656..65d463c12 100644 --- a/openapi.json +++ b/openapi.json @@ -702,7 +702,9 @@ "request_sign_date", "signed", "me", - "signRequestId" + "signRequestId", + "status", + "statusText" ], "properties": { "description": { @@ -768,6 +770,18 @@ "format": "int64", "minimum": 0 }, + "status": { + "type": "integer", + "format": "int64", + "enum": [ + 0, + 1, + 2 + ] + }, + "statusText": { + "type": "string" + }, "signingOrder": { "type": "integer", "format": "int64", diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index 554d3c929..716dc960b 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -1716,6 +1716,12 @@ export type components = { me: boolean; /** Format: int64 */ signRequestId: number; + /** + * Format: int64 + * @enum {integer} + */ + status: 0 | 1 | 2; + statusText: string; /** Format: int64 */ signingOrder?: number; identifyMethods?: components["schemas"]["IdentifyMethod"][]; diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index 77df93997..6fa82b007 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -1238,6 +1238,12 @@ export type components = { me: boolean; /** Format: int64 */ signRequestId: number; + /** + * Format: int64 + * @enum {integer} + */ + status: 0 | 1 | 2; + statusText: string; /** Format: int64 */ signingOrder?: number; identifyMethods?: components["schemas"]["IdentifyMethod"][];