Skip to content

Commit 0e0797c

Browse files
committed
return a message on the file action endpoint for the client integration
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent b254c4c commit 0e0797c

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎lib/Controller/AssistantApiController.php‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use OCP\IRequest;
2929
use OCP\Lock\LockedException;
3030
use OCP\TaskProcessing\Task;
31+
use OCP\TaskProcessing\TaskTypes\AudioToText;
32+
use OCP\TaskProcessing\TaskTypes\TextToTextSummary;
3133
use Psr\Log\LoggerInterface;
3234
use Throwable;
3335

@@ -418,16 +420,26 @@ public function getOutputFile(int $ocpTaskId, int $fileId): DataDownloadResponse
418420
*
419421
* @param int $fileId The input file ID
420422
* @param string $taskTypeId The task type of the operation to perform
421-
* @return DataResponse<Http::STATUS_OK, array{taskId: int}, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
423+
* @return DataResponse<Http::STATUS_OK, string, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
422424
*
423425
* 200: The task has been scheduled successfully
424426
* 400: There was an issue while scheduling the task
425427
*/
426428
#[NoAdminRequired]
427429
public function runFileAction(int $fileId, string $taskTypeId): DataResponse {
428430
try {
429-
$taskId = $this->taskProcessingService->runFileAction($this->userId, $fileId, $taskTypeId);
430-
return new DataResponse(['taskId' => $taskId]);
431+
$this->taskProcessingService->runFileAction($this->userId, $fileId, $taskTypeId);
432+
if ($taskTypeId === AudioToText::ID) {
433+
$message = $this->l10n->t('Transcription task submitted successfully');
434+
} elseif ($taskTypeId === TextToTextSummary::ID) {
435+
$message = $this->l10n->t('Summarization task submitted successfully');
436+
} elseif (class_exists('OCP\\TaskProcessing\\TaskTypes\\TextToSpeech')
437+
&& $taskTypeId === \OCP\TaskProcessing\TaskTypes\TextToSpeech::ID) {
438+
$message = $this->l10n->t('Text-to-speech task submitted successfully');
439+
} else {
440+
$message = $this->l10n->t('Assistant task submitted successfully');
441+
}
442+
return new DataResponse($message);
431443
} catch (Exception|Throwable $e) {
432444
return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
433445
}

‎openapi.json‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,16 +2195,7 @@
21952195
"$ref": "#/components/schemas/OCSMeta"
21962196
},
21972197
"data": {
2198-
"type": "object",
2199-
"required": [
2200-
"taskId"
2201-
],
2202-
"properties": {
2203-
"taskId": {
2204-
"type": "integer",
2205-
"format": "int64"
2206-
}
2207-
}
2198+
"type": "string"
22082199
}
22092200
}
22102201
}

‎src/files/fileActions.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function registerSummarizeAction() {
6262
const url = generateOcsUrl('/apps/assistant/api/v1/file-action/{fileId}/core:text2text:summary', { fileId: node.fileid })
6363
try {
6464
const response = await axios.post(url)
65-
console.debug('taskId', response.data.ocs.data.taskId)
6665
showSuccess(
6766
t('assistant', 'Summarization task submitted successfully.') + '\n'
6867
+ t('assistant', 'You will be notified when it is ready.') + '\n'
@@ -101,7 +100,6 @@ function registerTtsAction() {
101100
const url = generateOcsUrl('/apps/assistant/api/v1/file-action/{fileId}/core:text2speech', { fileId: node.fileid })
102101
try {
103102
const response = await axios.post(url)
104-
console.debug('taskId', response.data.ocs.data.taskId)
105103
showSuccess(
106104
t('assistant', 'Text-to-speech task submitted successfully.') + '\n'
107105
+ t('assistant', 'You will be notified when it is ready.') + '\n'
@@ -140,7 +138,6 @@ function registerSttAction() {
140138
const url = generateOcsUrl('/apps/assistant/api/v1/file-action/{fileId}/core:audio2text', { fileId: node.fileid })
141139
try {
142140
const response = await axios.post(url)
143-
console.debug('taskId', response.data.ocs.data.taskId)
144141
showSuccess(
145142
t('assistant', 'Transcription task submitted successfully.') + '\n'
146143
+ t('assistant', 'You will be notified when it is ready.') + '\n'

0 commit comments

Comments
 (0)