fix: respect status 0 (DRAFT) when adding new signers

When adding a new signer with status 0, the backend was ignoring it
because empty() treated 0 as falsy. Changed to isset() to properly
handle status 0.

Also updated determineInitialStatus() to allow new signers to be
added in DRAFT mode even when the file is not in DRAFT status,
allowing gradual signer addition before requesting signatures.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
Vitor Mattos 2025-12-11 15:14:34 -03:00
commit 6bd828e9ed
No known key found for this signature in database
GPG key ID: 6FECE2AD4809003A

View file

@ -53,7 +53,7 @@ class RequestSignatureService {
public function save(array $data): FileEntity {
$file = $this->saveFile($data);
$this->saveVisibleElements($data, $file);
if (empty($data['status'])) {
if (!isset($data['status'])) {
$data['status'] = $file->getStatus();
}
$this->associateToSigners($data, $file->getId());
@ -289,6 +289,8 @@ class RequestSignatureService {
}
private function determineInitialStatus(int $signingOrder, ?int $fileStatus = null): \OCA\Libresign\Enum\SignRequestStatus {
// If fileStatus is explicitly DRAFT (0), keep signer as DRAFT
// This allows adding new signers in DRAFT mode even when file is not in DRAFT status
if ($fileStatus === FileEntity::STATUS_DRAFT) {
return \OCA\Libresign\Enum\SignRequestStatus::DRAFT;
}