diff --git a/docs/images/dashboard-heading.jpg b/docs/images/dashboard-heading.jpg index 9b88bfe90..7d258cfe8 100644 Binary files a/docs/images/dashboard-heading.jpg and b/docs/images/dashboard-heading.jpg differ diff --git a/docs/images/join.jpg b/docs/images/join.jpg index 64f065212..526cff6f6 100644 Binary files a/docs/images/join.jpg and b/docs/images/join.jpg differ diff --git a/docs/images/joint-internal.jpg b/docs/images/joint-internal.jpg index df5b72515..c4fa202e1 100644 Binary files a/docs/images/joint-internal.jpg and b/docs/images/joint-internal.jpg differ diff --git a/docs/images/server.jpg b/docs/images/server.jpg index 0e85e9d5b..766427478 100644 Binary files a/docs/images/server.jpg and b/docs/images/server.jpg differ diff --git a/src/Command/CronSendReminderCommand.php b/src/Command/CronSendReminderCommand.php new file mode 100644 index 000000000..b8542313e --- /dev/null +++ b/src/Command/CronSendReminderCommand.php @@ -0,0 +1,51 @@ +reminderService = $reminderService; + } + + protected function configure() + { + $this + ->setDescription('Send a reminder to all users which are in a room in the next 10 min') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $res = $this->reminderService->sendReminder(); + + $io->writeln('Hinweis: '. $res['hinweis']); + $io->writeln('Konferenzen: '.$res['Konferenzen']); + $io->writeln('Emails: '.$res['Emails']); + $io->writeln('Datum: '.(new \DateTime())->format('d.m.Y')); + $io->writeln('Zeit: '.(new \DateTime())->format('H:i')); + if(!$res['error']){ + $io->success('Erfolgreich versandt'); + return Command::SUCCESS; + }else{ + $io->error('Fehler'); + return Command::FAILURE; + } + + + + } +} diff --git a/src/Controller/CronController.php b/src/Controller/CronController.php index a39b35e8d..9c253960e 100644 --- a/src/Controller/CronController.php +++ b/src/Controller/CronController.php @@ -4,6 +4,7 @@ use App\Entity\Rooms; +use App\Service\ReminderService; use App\Service\UserService; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -16,32 +17,13 @@ class CronController extends AbstractController /** * @Route("/cron/remember", name="cron_remember") */ - public function updateCronAkademie(Request $request, LoggerInterface $logger, UserService $userService) + public function updateCronAkademie(Request $request, LoggerInterface $logger, UserService $userService, ReminderService $reminderService) { if ($request->get('token') !== $this->getParameter('cronToken')) { $message = ['error' => true, 'hinweis' => 'Token fehlerhaft', 'token' => $request->get('token'), 'ip' => $request->getClientIp()]; $logger->error($message['hinweis'], $message); return new JsonResponse($message); } - $now10 = new \DateTime(); - $now10->modify('+ 10 minutes'); - - $qb = $this->getDoctrine()->getRepository(Rooms::class)->createQueryBuilder('rooms'); - $qb->where('rooms.start > :now') - ->andWhere('rooms.start < :now10') - ->setParameter('now10', $now10) - ->setParameter('now', new \DateTime()); - $query = $qb->getQuery(); - $rooms = $query->getResult(); - $emails = 0; - foreach ($rooms as $room) { - foreach ($room->getUser() as $data) { - $userService->notifyUser($data,$room); - ++ $emails; - } - } - - $message = ['error' => false, 'hinweis' => 'Cron ok', 'Konferenzen'=>count($rooms), 'Emails' => $emails]; - return new JsonResponse($message); + return new JsonResponse($reminderService->sendReminder()); } } diff --git a/src/Service/PexelService.php b/src/Service/PexelService.php index 05764e738..48921241a 100644 --- a/src/Service/PexelService.php +++ b/src/Service/PexelService.php @@ -24,7 +24,6 @@ public function getImageFromPexels() $image = null; try { $cache = new FilesystemAdapter(); - $cache->delete('pexels_image'); $value = $cache->get('pexels_image', function (ItemInterface $item) { $item->expiresAfter(intval($this->parameterBag->get('laF_pexel_refresh_time'))); diff --git a/src/Service/ReminderService.php b/src/Service/ReminderService.php new file mode 100644 index 000000000..21ed5b035 --- /dev/null +++ b/src/Service/ReminderService.php @@ -0,0 +1,47 @@ +em = $entityManager; + $this->parameterBag = $parameterBag; + $this->userService = $userService; + } + + public function sendReminder(){ + set_time_limit(600); + $now10 = new \DateTime(); + $now10->modify('+ 10 minutes'); + + $qb = $this->em->getRepository(Rooms::class)->createQueryBuilder('rooms'); + $qb->where('rooms.start > :now') + ->andWhere('rooms.start < :now10') + ->setParameter('now10', $now10) + ->setParameter('now', new \DateTime()); + $query = $qb->getQuery(); + $rooms = $query->getResult(); + $emails = 0; + foreach ($rooms as $room) { + foreach ($room->getUser() as $data) { + $this->userService->notifyUser($data,$room); + ++ $emails; + } + } + $message = ['error' => false, 'hinweis' => 'Cron ok', 'Konferenzen'=>count($rooms), 'Emails' => $emails]; + return $message; + } + +} \ No newline at end of file