diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index 80843a1..4f82622 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -72,6 +72,19 @@ class TicketService { return $this->resolveTicket($this->ticketMapper->insert($ticket)); } + + + public function assign($id, $userId): array{ + $matrixUser = $this->getOrCreateUser($userId); + $ticket = $this->ticketMapper->findTicket($id); + $roomID= $ticket->getMatrixRoom(); + $this->matrix->setProperty($roomID, "upschooling.ticket", array( + "matrixHelperUser" => $matrixUser->getMatrixUser() + )); + $ticket->setMatrixHelperUser($matrixUser->getMatrixUser()); + return $this->resolveTicket($this->ticketMapper->update($ticket)); + } + public function update($id, $title, $content, $userId) { throw new Exception("Not implemented"); } @@ -93,7 +106,7 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); - $matrixHelperUserName = array_get($matrixTicketContent, "matrixHelperUserName", "nicht zugewiesen"); + $matrixHelperUser = array_get($matrixTicketContent, "matrixHelperUser", "nicht zugewiesen"); $expirationDate = array_get($matrixTicketContent, "expiration date", ""); return array( 'ticketId' => $ticketId, @@ -101,7 +114,7 @@ class TicketService { 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, - 'matrixHelferName' => $matrixHelperUserName, + 'matrixHelperUser' => $matrixHelperUser, 'expirationDate' => $expirationDate ); } catch (MatrixException | RoomNotFoundException $e) {