summaryrefslogtreecommitdiffstats
path: root/core/Controller
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-05-06 13:03:03 +0200
committerMarcel Klehr <mklehr@gmx.net>2024-05-14 11:38:40 +0200
commit2c878099f1d2fbfc5b5d117c63fa8723d3e26f3d (patch)
tree7440a3171dc15a07cf296ddf3461d18862b70fbe /core/Controller
parent5de42a53e263d6dda1896ff223158646bd81867b (diff)
downloadnextcloud-server-2c878099f1d2fbfc5b5d117c63fa8723d3e26f3d.tar.gz
nextcloud-server-2c878099f1d2fbfc5b5d117c63fa8723d3e26f3d.zip
fix: address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/TaskProcessingApiController.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php
index e42e03424b8..2195d780f45 100644
--- a/core/Controller/TaskProcessingApiController.php
+++ b/core/Controller/TaskProcessingApiController.php
@@ -183,9 +183,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
$this->taskProcessingManager->deleteTask($task);
- return new DataResponse([]);
+ return new DataResponse(null);
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
- return new DataResponse([]);
+ return new DataResponse(null);
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
@@ -272,20 +272,22 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
$taskType = $taskTypes[$task->getTaskTypeId()];
foreach ($taskType['inputShape'] + $taskType['optionalInputShape'] as $key => $descriptor) {
if (in_array(EShapeType::getScalarType($descriptor->getShapeType()), [EShapeType::File, EShapeType::Image, EShapeType::Audio, EShapeType::Video], true)) {
- if (is_array($task->getInput()[$key])) {
- $ids += $task->getInput()[$key];
+ $inputSlot = $task->getInput()[$key];
+ if (is_array($inputSlot)) {
+ $ids += $inputSlot;
} else {
- $ids[] = $task->getInput()[$key];
+ $ids[] = $inputSlot;
}
}
}
if ($task->getOutput() !== null) {
foreach ($taskType['outputShape'] + $taskType['optionalOutputShape'] as $key => $descriptor) {
if (in_array(EShapeType::getScalarType($descriptor->getShapeType()), [EShapeType::File, EShapeType::Image, EShapeType::Audio, EShapeType::Video], true)) {
- if (is_array($task->getInput()[$key])) {
- $ids += $task->getOutput()[$key];
+ $outputSlot = $task->getOutput()[$key];
+ if (is_array($outputSlot)) {
+ $ids += $outputSlot;
} else {
- $ids[] = $task->getOutput()[$key];
+ $ids[] = $outputSlot;
}
}
}
@@ -338,7 +340,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
#[ApiRoute(verb: 'POST', url: '/tasks/{taskId}/result', root: '/taskprocessing')]
public function setResult(int $taskId, ?array $output = null, ?string $errorMessage = null): DataResponse {
try {
+ // Check if the current user can access the task
$this->taskProcessingManager->getUserTask($taskId, $this->userId);
+ // set result
$this->taskProcessingManager->setTaskResult($taskId, $errorMessage, $output);
$task = $this->taskProcessingManager->getUserTask($taskId, $this->userId);