From dd0ac0a0070e3a09b153d4dc55a8fc69c03a0d2d Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 17 Dec 2025 02:03:20 -0300 Subject: [PATCH] feat: add NONE mode to SignatureFlow enum Allow admin to not enforce signing flow, letting users choose per document. Updates enum, File entity, and migration defaults. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- lib/Db/File.php | 2 +- lib/Enum/SignatureFlow.php | 4 ++++ lib/Migration/Version15000Date20251209000000.php | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Db/File.php b/lib/Db/File.php index 07c112f51..04b93a1c2 100644 --- a/lib/Db/File.php +++ b/lib/Db/File.php @@ -57,7 +57,7 @@ class File extends Entity { protected ?string $callback = null; protected ?array $metadata = null; protected int $modificationStatus = 0; - protected int $signatureFlow = SignatureFlow::NUMERIC_PARALLEL; + protected int $signatureFlow = SignatureFlow::NUMERIC_NONE; protected int $docmdpLevel = 0; public const STATUS_NOT_LIBRESIGN_FILE = -1; public const STATUS_DRAFT = 0; diff --git a/lib/Enum/SignatureFlow.php b/lib/Enum/SignatureFlow.php index 71d31ba53..f0305c437 100644 --- a/lib/Enum/SignatureFlow.php +++ b/lib/Enum/SignatureFlow.php @@ -13,14 +13,17 @@ namespace OCA\Libresign\Enum; * Signature flow modes */ enum SignatureFlow: string { + case NONE = 'none'; case PARALLEL = 'parallel'; case ORDERED_NUMERIC = 'ordered_numeric'; + public const NUMERIC_NONE = 0; public const NUMERIC_PARALLEL = 1; public const NUMERIC_ORDERED_NUMERIC = 2; public function toNumeric(): int { return match($this) { + self::NONE => self::NUMERIC_NONE, self::PARALLEL => self::NUMERIC_PARALLEL, self::ORDERED_NUMERIC => self::NUMERIC_ORDERED_NUMERIC, }; @@ -28,6 +31,7 @@ enum SignatureFlow: string { public static function fromNumeric(int $value): self { return match($value) { + self::NUMERIC_NONE => self::NONE, self::NUMERIC_PARALLEL => self::PARALLEL, self::NUMERIC_ORDERED_NUMERIC => self::ORDERED_NUMERIC, default => throw new \ValueError("Invalid numeric value for SignatureFlow: $value"), diff --git a/lib/Migration/Version15000Date20251209000000.php b/lib/Migration/Version15000Date20251209000000.php index d68f3947e..fd183c665 100644 --- a/lib/Migration/Version15000Date20251209000000.php +++ b/lib/Migration/Version15000Date20251209000000.php @@ -62,8 +62,8 @@ class Version15000Date20251209000000 extends SimpleMigrationStep { if (!$tableFile->hasColumn('signature_flow')) { $tableFile->addColumn('signature_flow', Types::SMALLINT, [ 'notnull' => true, - 'default' => SignatureFlow::NUMERIC_PARALLEL, - 'comment' => 'Signature flow mode: 1=parallel, 2=ordered_numeric', + 'default' => SignatureFlow::NUMERIC_NONE, + 'comment' => 'Signature flow mode: 0=none (no admin enforcement), 1=parallel, 2=ordered_numeric', ]); } }