aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-07-19 12:38:30 +0200
committerGitHub <noreply@github.com>2024-07-19 12:38:30 +0200
commita3c3eab09c50bc7dd16e95e8689f3a03b1d2ac98 (patch)
tree4b832bf2b18e9468c0781d5f912626655b24cdaf /lib/public
parent64ca4b832dc6b7a574fd3301b1c0e022b192ea5d (diff)
parentff99df07e7212a3c8bfdcc3cf9a571353c6f84ff (diff)
downloadnextcloud-server-a3c3eab09c50bc7dd16e95e8689f3a03b1d2ac98.tar.gz
nextcloud-server-a3c3eab09c50bc7dd16e95e8689f3a03b1d2ac98.zip
Merge pull request #46368 from nextcloud/fix/task-processing
TaskProcessing follow-up
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/TaskProcessing/EShapeType.php36
-rw-r--r--lib/public/TaskProcessing/IManager.php6
2 files changed, 39 insertions, 3 deletions
diff --git a/lib/public/TaskProcessing/EShapeType.php b/lib/public/TaskProcessing/EShapeType.php
index d66de6e01a8..059f9d0c3c7 100644
--- a/lib/public/TaskProcessing/EShapeType.php
+++ b/lib/public/TaskProcessing/EShapeType.php
@@ -89,7 +89,7 @@ enum EShapeType: int {
* @throws ValidationException
* @since 30.0.0
*/
- public function validateOutput(mixed $value) {
+ public function validateOutputWithFileData(mixed $value): void {
$this->validateNonFileType($value);
if ($this === EShapeType::Image && !is_string($value)) {
throw new ValidationException('Non-image item provided for Image slot');
@@ -118,6 +118,40 @@ enum EShapeType: int {
}
/**
+ * @param mixed $value
+ * @return void
+ * @throws ValidationException
+ * @since 30.0.0
+ */
+ public function validateOutputWithFileIds(mixed $value): void {
+ $this->validateNonFileType($value);
+ if ($this === EShapeType::Image && !is_numeric($value)) {
+ throw new ValidationException('Non-image item provided for Image slot');
+ }
+ if ($this === EShapeType::ListOfImages && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
+ throw new ValidationException('Non-image list item provided for ListOfImages slot');
+ }
+ if ($this === EShapeType::Audio && !is_string($value)) {
+ throw new ValidationException('Non-audio item provided for Audio slot');
+ }
+ if ($this === EShapeType::ListOfAudios && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
+ throw new ValidationException('Non-audio list item provided for ListOfAudio slot');
+ }
+ if ($this === EShapeType::Video && !is_string($value)) {
+ throw new ValidationException('Non-video item provided for Video slot');
+ }
+ if ($this === EShapeType::ListOfVideos && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
+ throw new ValidationException('Non-video list item provided for ListOfTexts slot');
+ }
+ if ($this === EShapeType::File && !is_string($value)) {
+ throw new ValidationException('Non-file item provided for File slot');
+ }
+ if ($this === EShapeType::ListOfFiles && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) {
+ throw new ValidationException('Non-audio list item provided for ListOfFiles slot');
+ }
+ }
+
+ /**
* @param EShapeType $type
* @return EShapeType
* @since 30.0.0
diff --git a/lib/public/TaskProcessing/IManager.php b/lib/public/TaskProcessing/IManager.php
index 599bd244d8a..c68ad1afbac 100644
--- a/lib/public/TaskProcessing/IManager.php
+++ b/lib/public/TaskProcessing/IManager.php
@@ -91,11 +91,12 @@ interface IManager {
* @param int $id The id of the task
* @param string|null $error
* @param array|null $result
+ * @param bool $isUsingFileIds
* @throws Exception If the query failed
* @throws NotFoundException If the task could not be found
* @since 30.0.0
*/
- public function setTaskResult(int $id, ?string $error, ?array $result): void;
+ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isUsingFileIds = false): void;
/**
* @param int $id
@@ -152,7 +153,7 @@ interface IManager {
/**
* Prepare the task's input data, so it can be processed by the provider
- * ie. this replaces file ids with base64 data
+ * ie. this replaces file ids with File objects
*
* @param Task $task
* @return array<array-key, list<numeric|string|File>|numeric|string|File>
@@ -160,6 +161,7 @@ interface IManager {
* @throws GenericFileException
* @throws LockedException
* @throws ValidationException
+ * @throws UnauthorizedException
* @since 30.0.0
*/
public function prepareInputData(Task $task): array;