|
28 | 28 | use OCP\IRequest; |
29 | 29 | use OCP\Lock\LockedException; |
30 | 30 | use OCP\TaskProcessing\Task; |
| 31 | +use OCP\TaskProcessing\TaskTypes\AudioToText; |
| 32 | +use OCP\TaskProcessing\TaskTypes\TextToTextSummary; |
31 | 33 | use Psr\Log\LoggerInterface; |
32 | 34 | use Throwable; |
33 | 35 |
|
@@ -418,16 +420,26 @@ public function getOutputFile(int $ocpTaskId, int $fileId): DataDownloadResponse |
418 | 420 | * |
419 | 421 | * @param int $fileId The input file ID |
420 | 422 | * @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{}> |
422 | 424 | * |
423 | 425 | * 200: The task has been scheduled successfully |
424 | 426 | * 400: There was an issue while scheduling the task |
425 | 427 | */ |
426 | 428 | #[NoAdminRequired] |
427 | 429 | public function runFileAction(int $fileId, string $taskTypeId): DataResponse { |
428 | 430 | 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); |
431 | 443 | } catch (Exception|Throwable $e) { |
432 | 444 | return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
433 | 445 | } |
|
0 commit comments