Skip to content

Commit ae3894b

Browse files
authored
Merge pull request #6112 from LibreSign/backport/6111/stable31
[stable31] feat: add status text to signers
2 parents 282596b + f8ff832 commit ae3894b

9 files changed

Lines changed: 70 additions & 2 deletions

File tree

lib/Db/IdDocsMapper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ private function assocFileToSignRequestAndFormat(array $files, array $signers):
283283
->format('Y-m-d H:i:s'),
284284
'sign_date' => null,
285285
'signRequestId' => $signer->getId(),
286+
'status' => $signer->getStatus(),
287+
'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()),
286288
];
287289
if ($signer->getSigned()) {
288290
$data['sign_date'] = (new \DateTime())

lib/Db/SignRequestMapper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\Libresign\Db;
1010

1111
use DateTimeInterface;
12+
use OCA\Libresign\Enum\SignRequestStatus;
1213
use OCA\Libresign\Helper\Pagination;
1314
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
1415
use OCA\Libresign\Service\IdentifyMethodService;
@@ -639,4 +640,8 @@ private function removeExtensionFromName(string $name, ?string $metadataJson): s
639640
$result = preg_replace($extensionPattern, '', $name);
640641
return $result ?? $name;
641642
}
643+
644+
public function getTextOfSignerStatus(int $status): string {
645+
return SignRequestStatus::from($status)->getLabel($this->l10n);
646+
}
642647
}

lib/Enum/SignRequestStatus.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@
99

1010
namespace OCA\Libresign\Enum;
1111

12+
use OCP\IL10N;
13+
1214
enum SignRequestStatus: int {
1315
case DRAFT = 0;
1416
case ABLE_TO_SIGN = 1;
1517
case SIGNED = 2;
18+
19+
public function getLabel(IL10N $l10n): string {
20+
return match($this) {
21+
// TRANSLATORS Name of the status when signer document is in draft state
22+
self::DRAFT => $l10n->t('Draft'),
23+
// TRANSLATORS Name of the status when signer can sign the document
24+
self::ABLE_TO_SIGN => $l10n->t('Pending'),
25+
// TRANSLATORS Name of the status when signer has already signed
26+
self::SIGNED => $l10n->t('Signed'),
27+
};
28+
}
1629
}

lib/ResponseDefinitions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@
173173
* hash_algorithm?: string,
174174
* me: bool,
175175
* signRequestId: non-negative-int,
176+
* status: 0|1|2,
177+
* statusText: string,
176178
* signingOrder?: non-negative-int,
177179
* identifyMethods?: LibresignIdentifyMethod[],
178180
* visibleElements?: LibresignVisibleElement[],

lib/Service/FileService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ private function loadLibreSignSigners(): void {
387387
$this->fileData->signers[$index]['me'] = false;
388388
$this->fileData->signers[$index]['signRequestId'] = $signer->getId();
389389
$this->fileData->signers[$index]['description'] = $signer->getDescription();
390+
$this->fileData->signers[$index]['status'] = $signer->getStatus();
391+
$this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus());
390392
$this->fileData->signers[$index]['signingOrder'] = $signer->getSigningOrder();
391393
$this->fileData->signers[$index]['visibleElements'] = $this->getVisibleElements($signer->getId());
392394
$this->fileData->signers[$index]['request_sign_date'] = $signer->getCreatedAt()->format(DateTimeInterface::ATOM);
@@ -487,6 +489,9 @@ private function loadLibreSignSigners(): void {
487489
private function loadSignersFromCertData(): void {
488490
$this->loadCertDataFromLibreSignFile();
489491
foreach ($this->certData as $index => $signer) {
492+
$this->fileData->signers[$index]['status'] = 2;
493+
$this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus(2);
494+
490495
if (isset($signer['timestamp'])) {
491496
$this->fileData->signers[$index]['timestamp'] = $signer['timestamp'];
492497
if (isset($signer['timestamp']['genTime']) && $signer['timestamp']['genTime'] instanceof DateTimeInterface) {
@@ -836,6 +841,7 @@ private function associateAllAndFormat(IUser $user, array $files, array $signers
836841
'signRequestId' => $signer->getId(),
837842
'signingOrder' => $signer->getSigningOrder(),
838843
'status' => $signer->getStatus(),
844+
'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()),
839845
'me' => array_reduce($identifyMethodsOfSigner, function (bool $carry, IdentifyMethod $identifyMethod) use ($user): bool {
840846
if ($identifyMethod->getIdentifierKey() === IdentifyMethodService::IDENTIFY_ACCOUNT) {
841847
if ($user->getUID() === $identifyMethod->getIdentifierValue()) {

openapi-full.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,9 @@
852852
"request_sign_date",
853853
"signed",
854854
"me",
855-
"signRequestId"
855+
"signRequestId",
856+
"status",
857+
"statusText"
856858
],
857859
"properties": {
858860
"description": {
@@ -918,6 +920,18 @@
918920
"format": "int64",
919921
"minimum": 0
920922
},
923+
"status": {
924+
"type": "integer",
925+
"format": "int64",
926+
"enum": [
927+
0,
928+
1,
929+
2
930+
]
931+
},
932+
"statusText": {
933+
"type": "string"
934+
},
921935
"signingOrder": {
922936
"type": "integer",
923937
"format": "int64",

openapi.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,9 @@
702702
"request_sign_date",
703703
"signed",
704704
"me",
705-
"signRequestId"
705+
"signRequestId",
706+
"status",
707+
"statusText"
706708
],
707709
"properties": {
708710
"description": {
@@ -768,6 +770,18 @@
768770
"format": "int64",
769771
"minimum": 0
770772
},
773+
"status": {
774+
"type": "integer",
775+
"format": "int64",
776+
"enum": [
777+
0,
778+
1,
779+
2
780+
]
781+
},
782+
"statusText": {
783+
"type": "string"
784+
},
771785
"signingOrder": {
772786
"type": "integer",
773787
"format": "int64",

src/types/openapi/openapi-full.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,12 @@ export type components = {
17161716
me: boolean;
17171717
/** Format: int64 */
17181718
signRequestId: number;
1719+
/**
1720+
* Format: int64
1721+
* @enum {integer}
1722+
*/
1723+
status: 0 | 1 | 2;
1724+
statusText: string;
17191725
/** Format: int64 */
17201726
signingOrder?: number;
17211727
identifyMethods?: components["schemas"]["IdentifyMethod"][];

src/types/openapi/openapi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,12 @@ export type components = {
12381238
me: boolean;
12391239
/** Format: int64 */
12401240
signRequestId: number;
1241+
/**
1242+
* Format: int64
1243+
* @enum {integer}
1244+
*/
1245+
status: 0 | 1 | 2;
1246+
statusText: string;
12411247
/** Format: int64 */
12421248
signingOrder?: number;
12431249
identifyMethods?: components["schemas"]["IdentifyMethod"][];

0 commit comments

Comments
 (0)