add function to assign a Helper to a ticket

This commit is contained in:
Caluera 2021-10-10 19:07:53 +02:00
parent d17e40e56b
commit 8e44a5ea51

View file

@ -72,6 +72,19 @@ class TicketService {
return $this->resolveTicket($this->ticketMapper->insert($ticket)); 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) { public function update($id, $title, $content, $userId) {
throw new Exception("Not implemented"); throw new Exception("Not implemented");
} }
@ -93,7 +106,7 @@ class TicketService {
$title = array_get($matrixTicketContent, "title", "Untitled"); $title = array_get($matrixTicketContent, "title", "Untitled");
$description = array_get($matrixTicketContent, "description", ""); $description = array_get($matrixTicketContent, "description", "");
$lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); $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", ""); $expirationDate = array_get($matrixTicketContent, "expiration date", "");
return array( return array(
'ticketId' => $ticketId, 'ticketId' => $ticketId,
@ -101,7 +114,7 @@ class TicketService {
'lastModified' => $lastModified, 'lastModified' => $lastModified,
'title' => $title, 'title' => $title,
'description' => $description, 'description' => $description,
'matrixHelferName' => $matrixHelperUserName, 'matrixHelperUser' => $matrixHelperUser,
'expirationDate' => $expirationDate 'expirationDate' => $expirationDate
); );
} catch (MatrixException | RoomNotFoundException $e) { } catch (MatrixException | RoomNotFoundException $e) {