diff options
Diffstat (limited to 'core/Controller/TextProcessingApiController.php')
-rw-r--r-- | core/Controller/TextProcessingApiController.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/Controller/TextProcessingApiController.php b/core/Controller/TextProcessingApiController.php index 9ed332644e1..0f4c8c40b29 100644 --- a/core/Controller/TextProcessingApiController.php +++ b/core/Controller/TextProcessingApiController.php @@ -134,4 +134,36 @@ class TextProcessingApiController extends \OCP\AppFramework\OCSController { return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR); } } + + /** + * This endpoint returns a list of tasks related with a specific appId and identifier + * + * @PublicPage + * @UserRateThrottle(limit=20, period=120) + * + * @param string $appId + * @param string|null $identifier + * @return DataResponse<Http::STATUS_OK, array{tasks: array{CoreTextProcessingTask}}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}> + * + * 200: Task list returned + */ + public function listTasksByApp(string $appId, ?string $identifier = null): DataResponse { + if ($this->userId === null) { + return new DataResponse([ + 'tasks' => [], + ]); + } + try { + $tasks = $this->languageModelManager->getTasksByApp($this->userId, $appId, $identifier); + $json = array_map(static function (Task $task) { + return $task->jsonSerialize(); + }, $tasks); + + return new DataResponse([ + 'tasks' => $json, + ]); + } catch (\RuntimeException $e) { + return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR); + } + } } |