diff --git a/config/packages/zenstruck_schedule.yaml b/config/packages/zenstruck_schedule.yaml index 224488a..0f8c863 100644 --- a/config/packages/zenstruck_schedule.yaml +++ b/config/packages/zenstruck_schedule.yaml @@ -3,6 +3,9 @@ zenstruck_schedule: mailer: service: mailer + default_to: fromme@dreipunktnull.com + default_from: info@ep-reisen.de + subject_prefix: "[MyE&P-Team]" schedule_extensions: email_on_failure: @@ -28,3 +31,7 @@ zenstruck_schedule: - task: messenger:consume async -t 60 frequency: '*/5 * * * *' description: "Starts messenger queue" + + - task: app:cleanup:xml-dumps + frequency: "0 1 * * *" + description: "Removes outdated XML dumps of requests/responses to BPN API for debugging" diff --git a/src/Command/CleanupXMLDumpsCommand.php b/src/Command/CleanupXMLDumpsCommand.php new file mode 100644 index 0000000..4ab735e --- /dev/null +++ b/src/Command/CleanupXMLDumpsCommand.php @@ -0,0 +1,59 @@ +modify('-3 days')->getTimestamp(); + + try { + $files = $this + ->xmlDump + ->listContents('.') + ->filter(fn (StorageAttributes $attributes) => $attributes->isFile() && $attributes->lastModified() < $maxDate) + ->map(fn (StorageAttributes $attributes) => $attributes->path()) + ->toArray(); + } catch (FilesystemException $e) { + $io->error($e->getMessage()); + + return Command::FAILURE; + } + + foreach ($files as $file) { + $this->xmlDump->delete($file); + } + + $message = 'Removed '.count($files).' outdated XML dumps'; + + $this->logger->info($message); + $io->success($message); + + return Command::SUCCESS; + } +}