Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Db/IdDocsMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ private function assocFileToSignRequestAndFormat(array $files, array $signers):
->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())
Expand Down
5 changes: 5 additions & 0 deletions lib/Db/SignRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;
Expand Down Expand Up @@ -640,4 +641,8 @@ private function removeExtensionFromName(string $name, ?string $metadataJson): s
$result = preg_replace($extensionPattern, '', $name);
return $result ?? $name;
}

public function getTextOfSignerStatus(int $status): string {
return SignRequestStatus::from($status)->getLabel($this->l10n);
}
}
13 changes: 13 additions & 0 deletions lib/Enum/SignRequestStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@

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'),
};
}
}
2 changes: 2 additions & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
* hash_algorithm?: string,
* me: bool,
* signRequestId: non-negative-int,
* status: 0|1|2,
* statusText: string,
* signingOrder?: non-negative-int,
* identifyMethods?: LibresignIdentifyMethod[],
* visibleElements?: LibresignVisibleElement[],
Expand Down
6 changes: 6 additions & 0 deletions lib/Service/FileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ private function loadLibreSignSigners(): void {
$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);
Expand Down Expand Up @@ -487,6 +489,9 @@ private function loadLibreSignSigners(): void {
private function loadSignersFromCertData(): void {
$this->loadCertDataFromLibreSignFile();
foreach ($this->certData as $index => $signer) {
$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) {
Expand Down Expand Up @@ -836,6 +841,7 @@ private function associateAllAndFormat(IUser $user, array $files, array $signers
'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 {
if ($identifyMethod->getIdentifierKey() === IdentifyMethodService::IDENTIFY_ACCOUNT) {
if ($user->getUID() === $identifyMethod->getIdentifierValue()) {
Expand Down
16 changes: 15 additions & 1 deletion openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,9 @@
"request_sign_date",
"signed",
"me",
"signRequestId"
"signRequestId",
"status",
"statusText"
],
"properties": {
"description": {
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 15 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,9 @@
"request_sign_date",
"signed",
"me",
"signRequestId"
"signRequestId",
"status",
"statusText"
],
"properties": {
"description": {
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions src/types/openapi/openapi-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"][];
Expand Down
6 changes: 6 additions & 0 deletions src/types/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"][];
Expand Down
Loading