aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-05-02 15:12:35 +0200
committerMarcel Klehr <mklehr@gmx.net>2024-05-14 11:38:39 +0200
commit7a947980db9e8824a3c5c0f32a85af3f07a9ada9 (patch)
tree0b1b918de6ee96f65d44c8aaa7a83a5251ad5bc0 /core
parent1c033ae70a4a8a6d141e41a355cdcc38311eb966 (diff)
downloadnextcloud-server-7a947980db9e8824a3c5c0f32a85af3f07a9ada9.tar.gz
nextcloud-server-7a947980db9e8824a3c5c0f32a85af3f07a9ada9.zip
fix: Fix psalm issues
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/TaskProcessingApiController.php31
-rw-r--r--core/ResponseDefinitions.php6
2 files changed, 18 insertions, 19 deletions
diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php
index c3a2e9e0974..99d5755e10b 100644
--- a/core/Controller/TaskProcessingApiController.php
+++ b/core/Controller/TaskProcessingApiController.php
@@ -78,23 +78,27 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
public function taskTypes(): DataResponse {
$taskTypes = $this->taskProcessingManager->getAvailableTaskTypes();
- /** @var string $typeClass */
- foreach ($taskTypes as $taskType) {
- $taskType['inputShape'] = array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['inputShape']);
- $taskType['optionalInputShape'] = array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['optionalInputShape']);
- $taskType['outputShape'] = array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['outputShape']);
- $taskType['optionalOutputShape'] = array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['optionalOutputShape']);
+ $serializedTaskTypes = [];
+ foreach ($taskTypes as $key => $taskType) {
+ $serializedTaskTypes[$key] = [
+ 'name' => $taskType['name'],
+ 'description' => $taskType['description'],
+ 'inputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['inputShape']),
+ 'optionalInputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['optionalInputShape']),
+ 'outputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['outputShape']),
+ 'optionalOutputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['optionalOutputShape']),
+ ];
}
return new DataResponse([
- 'types' => $taskTypes,
+ 'types' => $serializedTaskTypes,
]);
}
/**
* This endpoint allows scheduling a task
*
- * @param string $input Input text
+ * @param array<array-key, mixed> $input Input text
* @param string $type Type of the task
* @param string $appId ID of the app that will execute the task
* @param string $identifier An arbitrary identifier for the task
@@ -162,10 +166,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
*
* @param int $id The id of the task
*
- * @return DataResponse<Http::STATUS_OK, array{task: CoreTaskProcessingTask}, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Task returned
- * 404: Task not found
*/
#[NoAdminRequired]
#[ApiRoute(verb: 'DELETE', url: '/task/{id}', root: '/taskprocessing')]
@@ -175,13 +178,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
$this->taskProcessingManager->deleteTask($task);
- $json = $task->jsonSerialize();
-
- return new DataResponse([
- 'task' => $json,
- ]);
+ return new DataResponse([]);
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
- return new DataResponse(['message' => $this->l->t('Task not found')], Http::STATUS_NOT_FOUND);
+ return new DataResponse([]);
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
diff --git a/core/ResponseDefinitions.php b/core/ResponseDefinitions.php
index 8025f7ef8a7..dd4196ec383 100644
--- a/core/ResponseDefinitions.php
+++ b/core/ResponseDefinitions.php
@@ -194,11 +194,11 @@ namespace OCA\Core;
*
* @psalm-type CoreTaskProcessingTask = array{
* id: ?int,
- * status: int,
+ * status: 0|1|2|3|4|5,
* userId: ?string,
* appId: string,
- * input: array<string, mixed>,
- * output: ?array<string, mixed>,
+ * input: ?array<array-key, mixed>,
+ * output: ?array<array-key, mixed>,
* identifier: ?string,
* completionExpectedAt: ?int,
* progress: ?float