From f8fe3c02d86d37f66b9c68cf85534aeccaf8105b Mon Sep 17 00:00:00 2001 From: Ante de Baas Date: Mon, 1 Jul 2024 20:49:27 +0200 Subject: [PATCH] various fixes --- dockerfiles/usr/local/bin/containerstartup.sh | 12 +++++++++- src/Command/GetReportsFromMailboxCommand.php | 6 ++--- src/Controller/ReportsController.php | 24 ------------------- src/Response/GetReportsResponse.php | 7 ------ .../{BaseResponse.php => MailboxResponse.php} | 2 +- templates/base.html.twig | 3 --- 6 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 src/Response/GetReportsResponse.php rename src/Response/{BaseResponse.php => MailboxResponse.php} (96%) diff --git a/dockerfiles/usr/local/bin/containerstartup.sh b/dockerfiles/usr/local/bin/containerstartup.sh index 66a437d..c090d06 100644 --- a/dockerfiles/usr/local/bin/containerstartup.sh +++ b/dockerfiles/usr/local/bin/containerstartup.sh @@ -15,9 +15,19 @@ if [ ! -f "/var/www/html/.env.local" ]; then echo "ENABLE_REGISTRATION=\"$ENABLE_REGISTRATION\"" >> /var/www/html/.env.local fi +echo "Check if attachments directory exists" +if test -d /path/to/directory; then + echo "Attachments directory exists." +else + echo "Attachments directory does not exist, creating it." + mkdir -p /var/www/html/var/imap/attachments + chown -R nobody:nobody /var/www/html/var/imap/attachments + chmod 775 /var/www/html/var/imap/attachments +fi + echo "Set cron schedule" if echo "$MAILCHECK_SCHEDULE" | egrep -s -q "^(@(monthly|weekly|daily|hourly|15min))|((((\d+,)+\d+|((\d+|\*)(\/|-)\d+)|\d+|\*) ?){5})$"; then - echo 'Cron schedule match found, following input'; + echo 'Cron schedule match found, following input schedule'; else echo 'Cron schedule match not found, setting to run once every hour'; MAILCHECK_SCHEDULE='0 * * * *'; diff --git a/src/Command/GetReportsFromMailboxCommand.php b/src/Command/GetReportsFromMailboxCommand.php index 9ad016c..02555c7 100644 --- a/src/Command/GetReportsFromMailboxCommand.php +++ b/src/Command/GetReportsFromMailboxCommand.php @@ -27,7 +27,7 @@ use App\Entity\Logs; use App\Entity\Config; -use App\Response\GetReportsResponse; +use App\Response\MailboxResponse; use App\Response\MailReportResponse; use App\Enums\ReportType; @@ -116,9 +116,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - private function open_mailbox(ConnectionInterface $ci_mailbox): GetReportsResponse + private function open_mailbox(ConnectionInterface $ci_mailbox): MailboxResponse { - $response = new GetReportsResponse(); + $response = new MailboxResponse(); $mailbox = $ci_mailbox->getMailbox(); $mail_ids = $mailbox->searchMailbox('UNSEEN'); diff --git a/src/Controller/ReportsController.php b/src/Controller/ReportsController.php index b553634..5d552a1 100644 --- a/src/Controller/ReportsController.php +++ b/src/Controller/ReportsController.php @@ -57,28 +57,4 @@ public function index(): Response 'breadcrumbs' => array(array('name' => $this->translator->trans("Reports"), 'url' => $this->router->generate('app_reports'))), ]); } - - #[Route('/reports/checkmailnow', name: 'app_checkmailnow')] - public function checkmailboxnow(): Response - { - if (!$this->getUser() || !$this->isGranted('IS_AUTHENTICATED')) { - return $this->redirectToRoute('app_login'); - } - - $this->denyAccessUnlessGranted('ROLE_ADMIN'); - - $kernel = new Kernel($_ENV['APP_ENV'], (bool) $_ENV['APP_DEBUG']); - - $application = new Application($kernel); - $application->setAutoExit(false); - - $input = new ArrayInput(array( - 'command' => 'app:getreportsfrommailbox' - )); - - $output = new BufferedOutput(); - $application->run($input, $output); - - return $this->redirectToRoute('app_dashboard'); - } } diff --git a/src/Response/GetReportsResponse.php b/src/Response/GetReportsResponse.php deleted file mode 100644 index 430a179..0000000 --- a/src/Response/GetReportsResponse.php +++ /dev/null @@ -1,7 +0,0 @@ -
- {% if app.user.getroles is defined and 'ROLE_ADMIN' in app.user.getroles() %} - Check mailbox now - {% endif %} {% if app.user.email is defined %}