Skip to content

Commit 6aaaf4d

Browse files
committed
feat(taskprocessing): add a boolean 'addWatermarking' to taskprocessing tasks
Signed-off-by: Julien Veyssier <[email protected]>
1 parent 38792c8 commit 6aaaf4d

File tree

11 files changed

+98
-8
lines changed

11 files changed

+98
-8
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OC\Core\Migrations;
10+
11+
use Closure;
12+
use OCP\DB\ISchemaWrapper;
13+
use OCP\DB\Types;
14+
use OCP\Migration\Attributes\AddColumn;
15+
use OCP\Migration\Attributes\ColumnType;
16+
use OCP\Migration\IOutput;
17+
use OCP\Migration\SimpleMigrationStep;
18+
19+
#[AddColumn(table: 'taskprocessing_tasks', name: 'add_watermarking', type: ColumnType::SMALLINT)]
20+
class Version33000Date20251126152410 extends SimpleMigrationStep {
21+
22+
/**
23+
* @param IOutput $output
24+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
25+
* @param array $options
26+
* @return null|ISchemaWrapper
27+
*/
28+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
29+
/** @var ISchemaWrapper $schema */
30+
$schema = $schemaClosure();
31+
32+
if ($schema->hasTable('taskprocessing_tasks')) {
33+
$table = $schema->getTable('taskprocessing_tasks');
34+
if (!$table->hasColumn('add_watermarking')) {
35+
$table->addColumn('add_watermarking', Types::SMALLINT, [
36+
'notnull' => true,
37+
'default' => 1,
38+
'unsigned' => true,
39+
]);
40+
return $schema;
41+
}
42+
}
43+
44+
return null;
45+
}
46+
}

core/ResponseDefinitions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
* startedAt: ?int,
212212
* endedAt: ?int,
213213
* allowCleanup: bool,
214+
* addWatermarking: bool,
214215
* }
215216
*
216217
* @psalm-type CoreProfileAction = array{

core/openapi-ex_app.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@
165165
"scheduledAt",
166166
"startedAt",
167167
"endedAt",
168-
"allowCleanup"
168+
"allowCleanup",
169+
"addWatermarking"
169170
],
170171
"properties": {
171172
"id": {
@@ -239,6 +240,9 @@
239240
},
240241
"allowCleanup": {
241242
"type": "boolean"
243+
},
244+
"addWatermarking": {
245+
"type": "boolean"
242246
}
243247
}
244248
}

core/openapi-full.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@
659659
"scheduledAt",
660660
"startedAt",
661661
"endedAt",
662-
"allowCleanup"
662+
"allowCleanup",
663+
"addWatermarking"
663664
],
664665
"properties": {
665666
"id": {
@@ -733,6 +734,9 @@
733734
},
734735
"allowCleanup": {
735736
"type": "boolean"
737+
},
738+
"addWatermarking": {
739+
"type": "boolean"
736740
}
737741
}
738742
},

core/openapi.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@
659659
"scheduledAt",
660660
"startedAt",
661661
"endedAt",
662-
"allowCleanup"
662+
"allowCleanup",
663+
"addWatermarking"
663664
],
664665
"properties": {
665666
"id": {
@@ -733,6 +734,9 @@
733734
},
734735
"allowCleanup": {
735736
"type": "boolean"
737+
},
738+
"addWatermarking": {
739+
"type": "boolean"
736740
}
737741
}
738742
},

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@
15361536
'OC\\Core\\Migrations\\Version33000Date20251023110529' => $baseDir . '/core/Migrations/Version33000Date20251023110529.php',
15371537
'OC\\Core\\Migrations\\Version33000Date20251023120529' => $baseDir . '/core/Migrations/Version33000Date20251023120529.php',
15381538
'OC\\Core\\Migrations\\Version33000Date20251106131209' => $baseDir . '/core/Migrations/Version33000Date20251106131209.php',
1539+
'OC\\Core\\Migrations\\Version33000Date20251126152410' => $baseDir . '/core/Migrations/Version33000Date20251126152410.php',
15391540
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
15401541
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',
15411542
'OC\\Core\\Service\\CronService' => $baseDir . '/core/Service/CronService.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
15771577
'OC\\Core\\Migrations\\Version33000Date20251023110529' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251023110529.php',
15781578
'OC\\Core\\Migrations\\Version33000Date20251023120529' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251023120529.php',
15791579
'OC\\Core\\Migrations\\Version33000Date20251106131209' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251106131209.php',
1580+
'OC\\Core\\Migrations\\Version33000Date20251126152410' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251126152410.php',
15801581
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
15811582
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',
15821583
'OC\\Core\\Service\\CronService' => __DIR__ . '/../../..' . '/core/Service/CronService.php',

lib/private/TaskProcessing/Db/Task.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
* @method int getAllowCleanup()
5050
* @method setUserFacingErrorMessage(null|string $message)
5151
* @method null|string getUserFacingErrorMessage()
52+
* @method setAddWatermarking(int $addWatermarking)
53+
* @method int getAddWatermarking()
5254
*/
5355
class Task extends Entity {
5456
protected $lastUpdated;
@@ -69,16 +71,17 @@ class Task extends Entity {
6971
protected $endedAt;
7072
protected $allowCleanup;
7173
protected $userFacingErrorMessage;
74+
protected $addWatermarking;
7275

7376
/**
7477
* @var string[]
7578
*/
76-
public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress', 'webhook_uri', 'webhook_method', 'scheduled_at', 'started_at', 'ended_at', 'allow_cleanup', 'user_facing_error_message'];
79+
public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress', 'webhook_uri', 'webhook_method', 'scheduled_at', 'started_at', 'ended_at', 'allow_cleanup', 'user_facing_error_message', 'add_watermarking'];
7780

7881
/**
7982
* @var string[]
8083
*/
81-
public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress', 'webhookUri', 'webhookMethod', 'scheduledAt', 'startedAt', 'endedAt', 'allowCleanup', 'userFacingErrorMessage'];
84+
public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress', 'webhookUri', 'webhookMethod', 'scheduledAt', 'startedAt', 'endedAt', 'allowCleanup', 'userFacingErrorMessage', 'addWatermarking'];
8285

8386

8487
public function __construct() {
@@ -102,6 +105,7 @@ public function __construct() {
102105
$this->addType('endedAt', 'integer');
103106
$this->addType('allowCleanup', 'integer');
104107
$this->addType('userFacingErrorMessage', 'string');
108+
$this->addType('addWatermarking', 'integer');
105109
}
106110

107111
public function toRow(): array {
@@ -132,6 +136,7 @@ public static function fromPublicTask(OCPTask $task): self {
132136
'endedAt' => $task->getEndedAt(),
133137
'allowCleanup' => $task->getAllowCleanup() ? 1 : 0,
134138
'userFacingErrorMessage' => $task->getUserFacingErrorMessage(),
139+
'addWatermarking' => $task->getAddWatermarking() ? 1 : 0,
135140
]);
136141
return $taskEntity;
137142
}
@@ -156,6 +161,7 @@ public function toPublicTask(): OCPTask {
156161
$task->setEndedAt($this->getEndedAt());
157162
$task->setAllowCleanup($this->getAllowCleanup() !== 0);
158163
$task->setUserFacingErrorMessage($this->getUserFacingErrorMessage());
164+
$task->setAddWatermarking($this->getAddWatermarking() !== 0);
159165
return $task;
160166
}
161167
}

lib/public/TaskProcessing/Task.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ final class Task implements \JsonSerializable {
4949

5050
protected ?string $userFacingErrorMessage = null;
5151

52+
protected bool $addWatermarking = true;
53+
5254
/**
5355
* @since 30.0.0
5456
*/
@@ -277,7 +279,23 @@ final public function setAllowCleanup(bool $allowCleanup): void {
277279
}
278280

279281
/**
280-
* @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int, allowCleanup: bool}
282+
* @return bool
283+
* @since 33.0.0
284+
*/
285+
final public function getAddWatermarking(): bool {
286+
return $this->addWatermarking;
287+
}
288+
289+
/**
290+
* @param bool $addWatermarking
291+
* @since 33.0.0
292+
*/
293+
final public function setAddWatermarking(bool $addWatermarking): void {
294+
$this->addWatermarking = $addWatermarking;
295+
}
296+
297+
/**
298+
* @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int, allowCleanup: bool, addWatermarking: bool}
281299
* @since 30.0.0
282300
*/
283301
final public function jsonSerialize(): array {
@@ -297,6 +315,7 @@ final public function jsonSerialize(): array {
297315
'startedAt' => $this->getStartedAt(),
298316
'endedAt' => $this->getEndedAt(),
299317
'allowCleanup' => $this->getAllowCleanup(),
318+
'addWatermarking' => $this->getAddWatermarking(),
300319
];
301320
}
302321

openapi.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@
701701
"scheduledAt",
702702
"startedAt",
703703
"endedAt",
704-
"allowCleanup"
704+
"allowCleanup",
705+
"addWatermarking"
705706
],
706707
"properties": {
707708
"id": {
@@ -775,6 +776,9 @@
775776
},
776777
"allowCleanup": {
777778
"type": "boolean"
779+
},
780+
"addWatermarking": {
781+
"type": "boolean"
778782
}
779783
}
780784
},

0 commit comments

Comments
 (0)