diff options
author | Julien Veyssier <julien-nc@posteo.net> | 2025-01-08 16:35:43 +0100 |
---|---|---|
committer | Julien Veyssier <julien-nc@posteo.net> | 2025-01-09 10:06:25 +0100 |
commit | 24332e2a065fcf0d363f690243e92d9badb4a3c3 (patch) | |
tree | 2ae96ee0fe2c9fb0b51aa16ca5c59a1e3e37bc8d /core/Controller/TaskProcessingApiController.php | |
parent | 4a3fceaf89b3a51185e7e1a23d0857a1a4b2d9c0 (diff) | |
download | nextcloud-server-24332e2a065fcf0d363f690243e92d9badb4a3c3.tar.gz nextcloud-server-24332e2a065fcf0d363f690243e92d9badb4a3c3.zip |
fix(taskprocessing): /tasktypes endpoint was broken by #49015
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'core/Controller/TaskProcessingApiController.php')
-rw-r--r-- | core/Controller/TaskProcessingApiController.php | 80 |
1 files changed, 60 insertions, 20 deletions
diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php index 925d4751383..2f5a81ea7a8 100644 --- a/core/Controller/TaskProcessingApiController.php +++ b/core/Controller/TaskProcessingApiController.php @@ -39,6 +39,7 @@ use OCP\TaskProcessing\IManager; use OCP\TaskProcessing\ShapeEnumValue; use OCP\TaskProcessing\Task; use RuntimeException; +use stdClass; /** * @psalm-import-type CoreTaskProcessingTask from ResponseDefinitions @@ -67,31 +68,70 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController { #[PublicPage] #[ApiRoute(verb: 'GET', url: '/tasktypes', root: '/taskprocessing')] public function taskTypes(): DataResponse { + /** @var array<string, CoreTaskProcessingTaskType> $taskTypes */ $taskTypes = array_map(function (array $tt) { - $tt['inputShape'] = array_values(array_map(function ($descriptor) { + $tt['inputShape'] = array_map(function ($descriptor) { return $descriptor->jsonSerialize(); - }, $tt['inputShape'])); - $tt['outputShape'] = array_values(array_map(function ($descriptor) { + }, $tt['inputShape']); + if (empty($tt['inputShape'])) { + $tt['inputShape'] = new stdClass; + } + + $tt['outputShape'] = array_map(function ($descriptor) { return $descriptor->jsonSerialize(); - }, $tt['outputShape'])); - $tt['optionalInputShape'] = array_values(array_map(function ($descriptor) { + }, $tt['outputShape']); + if (empty($tt['outputShape'])) { + $tt['outputShape'] = new stdClass; + } + + $tt['optionalInputShape'] = array_map(function ($descriptor) { return $descriptor->jsonSerialize(); - }, $tt['optionalInputShape'])); - $tt['optionalOutputShape'] = array_values(array_map(function ($descriptor) { + }, $tt['optionalInputShape']); + if (empty($tt['optionalInputShape'])) { + $tt['optionalInputShape'] = new stdClass; + } + + $tt['optionalOutputShape'] = array_map(function ($descriptor) { return $descriptor->jsonSerialize(); - }, $tt['optionalOutputShape'])); - $tt['inputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); - }, $tt['inputShapeEnumValues'])); - $tt['optionalInputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); - }, $tt['optionalInputShapeEnumValues'])); - $tt['outputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); - }, $tt['outputShapeEnumValues'])); - $tt['optionalOutputShapeEnumValues'] = array_values(array_map(function (array $enumValues) { - return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues)); - }, $tt['optionalOutputShapeEnumValues'])); + }, $tt['optionalOutputShape']); + if (empty($tt['optionalOutputShape'])) { + $tt['optionalOutputShape'] = new stdClass; + } + + $tt['inputShapeEnumValues'] = array_map(function (array $enumValues) { + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); + }, $tt['inputShapeEnumValues']); + if (empty($tt['inputShapeEnumValues'])) { + $tt['inputShapeEnumValues'] = new stdClass; + } + + $tt['optionalInputShapeEnumValues'] = array_map(function (array $enumValues) { + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); + }, $tt['optionalInputShapeEnumValues']); + if (empty($tt['optionalInputShapeEnumValues'])) { + $tt['optionalInputShapeEnumValues'] = new stdClass; + } + + $tt['outputShapeEnumValues'] = array_map(function (array $enumValues) { + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); + }, $tt['outputShapeEnumValues']); + if (empty($tt['outputShapeEnumValues'])) { + $tt['outputShapeEnumValues'] = new stdClass; + } + + $tt['optionalOutputShapeEnumValues'] = array_map(function (array $enumValues) { + return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); + }, $tt['optionalOutputShapeEnumValues']); + if (empty($tt['optionalOutputShapeEnumValues'])) { + $tt['optionalOutputShapeEnumValues'] = new stdClass; + } + + if (empty($tt['inputShapeDefaults'])) { + $tt['inputShapeDefaults'] = new stdClass; + } + if (empty($tt['optionalInputShapeDefaults'])) { + $tt['optionalInputShapeDefaults'] = new stdClass; + } return $tt; }, $this->taskProcessingManager->getAvailableTaskTypes()); return new DataResponse([ |