From 746bdf80643a164a8fc6887e84421de8b2c8e6f1 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 26 May 2026 09:42:53 +0200 Subject: [PATCH] feat(assignments): Add nice titles Signed-off-by: Marcel Klehr --- lib/Controller/AssignmentsApiController.php | 5 +++-- lib/Service/AssignmentsService.php | 4 ++-- openapi.json | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Controller/AssignmentsApiController.php b/lib/Controller/AssignmentsApiController.php index 631dd257..ee556d44 100644 --- a/lib/Controller/AssignmentsApiController.php +++ b/lib/Controller/AssignmentsApiController.php @@ -45,6 +45,7 @@ public function __construct( /** * Create a new assignment + * @param string $title The title of the new assignment * @param string $prompt The prompt to be sent to the assistant when the assignment is executed * @param int $startsAt The timestamp when the assignment should start being executed * @param string $recurrence The recurrence rule for the assignment, in RRULE format (e.g. "FREQ=DAILY;INTERVAL=1" for a daily assignment) @@ -57,9 +58,9 @@ public function __construct( #[NoAdminRequired] #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['assignments'])] #[Http\Attribute\ApiRoute(verb: 'POST', url: '/assignments')] - public function createUserAssignment(string $prompt, int $startsAt, string $recurrence): DataResponse { + public function createUserAssignment(string $title, string $prompt, int $startsAt, string $recurrence): DataResponse { try { - $assignment = $this->assignmentsService->createAssignment($this->userId, $prompt, $startsAt, $recurrence); + $assignment = $this->assignmentsService->createAssignment($this->userId, $title, $prompt, $startsAt, $recurrence); $serializedAssignment = $assignment->jsonSerialize(); return new DataResponse(['assignment' => $serializedAssignment]); } catch (InternalException $e) { diff --git a/lib/Service/AssignmentsService.php b/lib/Service/AssignmentsService.php index 99de5366..631b6f70 100644 --- a/lib/Service/AssignmentsService.php +++ b/lib/Service/AssignmentsService.php @@ -39,7 +39,7 @@ public function __construct( * @throws UnauthorizedException * @throws BadRequestException */ - public function createAssignment(?string $userId, string $prompt, int $startsAt, string $recurrence): Assignment { + public function createAssignment(?string $userId, string $title, string $prompt, int $startsAt, string $recurrence): Assignment { if ($userId === null) { throw new UnauthorizedException(); } @@ -61,7 +61,7 @@ public function createAssignment(?string $userId, string $prompt, int $startsAt, } catch (Exception $e) { throw new InternalException(previous: $e); } - $session = $this->chatService->createChatSession($userId, $this->timeFactory->now()->getTimestamp(), 'Assignment ' . $assignment->getId()); // TODO: Add a proper title here + $session = $this->chatService->createChatSession($userId, $this->timeFactory->now()->getTimestamp(), $title); $session->setAssignmentId($assignment->getId()); try { $this->sessionMapper->update($session); diff --git a/openapi.json b/openapi.json index 7bd328db..310f79b7 100644 --- a/openapi.json +++ b/openapi.json @@ -5334,11 +5334,16 @@ "schema": { "type": "object", "required": [ + "title", "prompt", "startsAt", "recurrence" ], "properties": { + "title": { + "type": "string", + "description": "The title of the new assignment" + }, "prompt": { "type": "string", "description": "The prompt to be sent to the assistant when the assignment is executed"