Skip to content

Commit 19968c4

Browse files
feat(File): add modification status constants and property
Add DocMDP modification tracking to File entity: - MODIFICATION_UNCHECKED (0): Not yet checked - MODIFICATION_UNMODIFIED (1): No modifications detected - MODIFICATION_ALLOWED (2): Modifications within DocMDP permissions - MODIFICATION_VIOLATION (3): Unauthorized modifications detected Add modificationStatus property (SMALLINT) to track PDF modification state after signature validation. Signed-off-by: Vitor Mattos <[email protected]>
1 parent 50c9084 commit 19968c4

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

lib/Db/File.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
* @method int getStatus()
3737
* @method void setMetadata(array $metadata)
3838
* @method ?array getMetadata()
39+
* @method void setModificationStatus(int $modificationStatus)
40+
* @method int getModificationStatus()
3941
*/
4042
class File extends Entity {
4143
protected int $nodeId = 0;
@@ -49,13 +51,19 @@ class File extends Entity {
4951
protected ?string $signedHash = null;
5052
protected ?string $callback = null;
5153
protected ?array $metadata = null;
54+
protected int $modificationStatus = 0;
5255
public const STATUS_NOT_LIBRESIGN_FILE = -1;
5356
public const STATUS_DRAFT = 0;
5457
public const STATUS_ABLE_TO_SIGN = 1;
5558
public const STATUS_PARTIAL_SIGNED = 2;
5659
public const STATUS_SIGNED = 3;
5760
public const STATUS_DELETED = 4;
5861

62+
public const MODIFICATION_UNCHECKED = 0;
63+
public const MODIFICATION_UNMODIFIED = 1;
64+
public const MODIFICATION_ALLOWED = 2;
65+
public const MODIFICATION_VIOLATION = 3;
66+
5967
public function __construct() {
6068
$this->addType('id', Types::INTEGER);
6169
$this->addType('nodeId', Types::INTEGER);
@@ -69,6 +77,7 @@ public function __construct() {
6977
$this->addType('callback', Types::STRING);
7078
$this->addType('status', Types::INTEGER);
7179
$this->addType('metadata', Types::JSON);
80+
$this->addType('modificationStatus', Types::SMALLINT);
7281
}
7382

7483
public function isDeletedAccount(): bool {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
9+
namespace OCA\Libresign\Migration;
10+
11+
use Closure;
12+
use OCP\DB\ISchemaWrapper;
13+
use OCP\DB\Types;
14+
use OCP\Migration\IOutput;
15+
use OCP\Migration\SimpleMigrationStep;
16+
17+
class Version14000Date20251206120000 extends SimpleMigrationStep {
18+
/**
19+
* @param IOutput $output
20+
* @param Closure(): ISchemaWrapper $schemaClosure
21+
* @param array $options
22+
* @return null|ISchemaWrapper
23+
*/
24+
#[\Override]
25+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
26+
/** @var ISchemaWrapper $schema */
27+
$schema = $schemaClosure();
28+
$table = $schema->getTable('libresign_file');
29+
30+
if (!$table->hasColumn('modification_status')) {
31+
$table->addColumn('modification_status', Types::SMALLINT, [
32+
'notnull' => true,
33+
'default' => 0,
34+
'comment' => 'DocMDP modification detection status: 0=unchecked, 1=unmodified, 2=allowed, 3=violation',
35+
]);
36+
return $schema;
37+
}
38+
39+
return null;
40+
}
41+
}

0 commit comments

Comments
 (0)