getNumberOfErrorTrials()) { throw new AccessDeniedHttpException('number of trials exceeded, no more access allowed'); } if ($verificationKey !== $workflowSend->getPrivateToken()) { $this->chillLogger->info(self::LOG_PREFIX.'Invalid trial for this send', ['client_ip' => $request->getClientIp()]); $workflowSend->increaseErrorTrials(); $this->entityManager->flush(); throw new AccessDeniedHttpException('invalid verification key'); } if ($this->clock->now() > $workflowSend->getExpireAt()) { return new Response( $this->environment->render('@ChillMain/Workflow/workflow_view_send_public_expired.html.twig'), 409 ); } if (100 < $workflowSend->getViews()->count()) { $this->chillLogger->info(self::LOG_PREFIX.'100 view reached, not allowed to see it again'); throw new AccessDeniedHttpException('100 views reached, not allowed to see it again'); } try { $metadata = new EntityWorkflowViewMetadataDTO( $workflowSend->getViews()->count(), 100 - $workflowSend->getViews()->count(), ); $response = new Response( $this->entityWorkflowManager->renderPublicView($workflowSend, $metadata), ); $view = new EntityWorkflowSendView($workflowSend, $this->clock->now(), $request->getClientIp()); $this->entityManager->persist($view); $this->messageBus->dispatch(new PostPublicViewMessage($view->getId())); $this->entityManager->flush(); return $response; } catch (HandlerWithPublicViewNotFoundException $e) { throw new \RuntimeException('Could not render the public view', previous: $e); } } }