diff options
author | Julien Veyssier <julien-nc@posteo.net> | 2023-08-02 16:47:41 +0200 |
---|---|---|
committer | Julien Veyssier <julien-nc@posteo.net> | 2023-08-09 14:58:02 +0200 |
commit | 6eb18570c0822ed1d774c5243e153fd0ee406fd1 (patch) | |
tree | 9d29f5cdfba7cd6ae844669b2f3cae82cf1399d8 /core/Controller | |
parent | 41918cc8b2e942a14c95dfadc9dffc65daf23f47 (diff) | |
download | nextcloud-server-6eb18570c0822ed1d774c5243e153fd0ee406fd1.tar.gz nextcloud-server-6eb18570c0822ed1d774c5243e153fd0ee406fd1.zip |
start implementing ocs endpoint to get task list from user+appId+identifier
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
(cherry picked from commit 9986e02097e5c82e1bb21ba3f897b14d82a50c15)
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'core/Controller')
-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); + } + } } |