From 8e44a5ea517da8ceaaac7e10da64f573bdb92e9f Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 19:07:53 +0200 Subject: [PATCH] add function to assign a Helper to a ticket --- lib/Service/TicketService.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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) {