Skip to content

Commit 7f32875

Browse files
committed
return JSONResponse in the file action endpoint for clients
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 81bf6fc commit 7f32875

2 files changed

Lines changed: 15 additions & 54 deletions

File tree

lib/Controller/AssistantApiController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\AppFramework\Http\Attribute\OpenAPI;
1919
use OCP\AppFramework\Http\DataDownloadResponse;
2020
use OCP\AppFramework\Http\DataResponse;
21+
use OCP\AppFramework\Http\JSONResponse;
2122
use OCP\AppFramework\Http\RedirectResponse;
2223
use OCP\AppFramework\OCSController;
2324
use OCP\DB\Exception;
@@ -420,13 +421,13 @@ public function getOutputFile(int $ocpTaskId, int $fileId): DataDownloadResponse
420421
*
421422
* @param int $fileId The input file ID
422423
* @param string $taskTypeId The task type of the operation to perform
423-
* @return DataResponse<Http::STATUS_OK, array{version: string, tooltip: string}, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
424+
* @return JSONResponse<Http::STATUS_OK, array{version: string, tooltip: string}, array{}>|JSONResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
424425
*
425426
* 200: The task has been scheduled successfully
426427
* 400: There was an issue while scheduling the task
427428
*/
428429
#[NoAdminRequired]
429-
public function runFileAction(int $fileId, string $taskTypeId): DataResponse {
430+
public function runFileAction(int $fileId, string $taskTypeId): JSONResponse {
430431
try {
431432
$this->taskProcessingService->runFileAction($this->userId, $fileId, $taskTypeId);
432433
$message = $this->l10n->t('Assistant task submitted successfully');
@@ -439,12 +440,12 @@ public function runFileAction(int $fileId, string $taskTypeId): DataResponse {
439440
$message = $this->l10n->t('Text-to-speech task submitted successfully');
440441
}
441442
}
442-
return new DataResponse([
443+
return new JSONResponse([
443444
'version' => '0.1',
444445
'tooltip' => $message,
445446
]);
446447
} catch (Exception|Throwable $e) {
447-
return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
448+
return new JSONResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
448449
}
449450
}
450451
}

openapi.json

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,35 +2545,15 @@
25452545
"schema": {
25462546
"type": "object",
25472547
"required": [
2548-
"ocs"
2548+
"version",
2549+
"tooltip"
25492550
],
25502551
"properties": {
2551-
"ocs": {
2552-
"type": "object",
2553-
"required": [
2554-
"meta",
2555-
"data"
2556-
],
2557-
"properties": {
2558-
"meta": {
2559-
"$ref": "#/components/schemas/OCSMeta"
2560-
},
2561-
"data": {
2562-
"type": "object",
2563-
"required": [
2564-
"version",
2565-
"tooltip"
2566-
],
2567-
"properties": {
2568-
"version": {
2569-
"type": "string"
2570-
},
2571-
"tooltip": {
2572-
"type": "string"
2573-
}
2574-
}
2575-
}
2576-
}
2552+
"version": {
2553+
"type": "string"
2554+
},
2555+
"tooltip": {
2556+
"type": "string"
25772557
}
25782558
}
25792559
}
@@ -2587,31 +2567,11 @@
25872567
"schema": {
25882568
"type": "object",
25892569
"required": [
2590-
"ocs"
2570+
"error"
25912571
],
25922572
"properties": {
2593-
"ocs": {
2594-
"type": "object",
2595-
"required": [
2596-
"meta",
2597-
"data"
2598-
],
2599-
"properties": {
2600-
"meta": {
2601-
"$ref": "#/components/schemas/OCSMeta"
2602-
},
2603-
"data": {
2604-
"type": "object",
2605-
"required": [
2606-
"error"
2607-
],
2608-
"properties": {
2609-
"error": {
2610-
"type": "string"
2611-
}
2612-
}
2613-
}
2614-
}
2573+
"error": {
2574+
"type": "string"
26152575
}
26162576
}
26172577
}

0 commit comments

Comments
 (0)