logger = $logger; $this->ticketService = $ticketService; $this->ticketMapper = $ticketMapper; $this->matrixService = $matrixService; $this->userId = $userId; } /** * @NoAdminRequired */ public function index(): DataResponse { return new DataResponse($this->ticketService->findAll($this->userId)); } /** * @NoAdminRequired */ public function show(int $id): DataResponse { return $this->handleNotFound(function () use ($id) { return $this->ticketService->find($id, $this->userId); }); } /** * @NoAdminRequired */ public function fetchChat(int $id): DataResponse { return $this->handleNotFound(function () use ($id) { $matrixUser = $this->ticketService->getOrCreateUser($this->userId); $ticket = $this->ticketMapper->findForUser($id, $matrixUser); $this->logger->debug("fetchChat found matrix data for room " . $ticket->getMatrixRoom()); return array( 'matrixRoom' => $ticket->getMatrixRoom(), // FIXME: wrong room, create one for helper and user 'matrixAccessToken' => $matrixUser->getMatrixToken(), 'matrixServerUrl' => $this->matrixService->getServerUrl(), ); }); } /** * @NoAdminRequired */ public function create(string $title, string $content): DataResponse { return new DataResponse($this->ticketService->create($title, $content, $this->userId)); } /** * @NoAdminRequired */ public function update(int $id): DataResponse { return new DataResponse($this->ticketService->assign($id, $this->userId)); } public function destroy(int $id): DataResponse { return $this->handleNotFound(function () use ($id) { return $this->ticketService->delete($id, $this->userId); }); } }