Schnellerkennung von Portalbuchungen per E-Mail

- IMAP-Abruf jede Minute (webklex/php-imap, ohne PHP-imap-Erweiterung) oder signierter Push von n8n
- Parser für Buchungs-, Storno- und Anfrage-Mails (de/en), Buchungsnummer, An-/Abreise
- Erkannte Buchungen werden sofort gesperrt und an handgepflegte Portale weitergegeben; Kalender-Abgleich übernimmt bzw. ersetzt Mail-Sperren
- Unklare Mails: Prüf-Mail + Admin-Liste Portal-E-Mails mit Aktion Sperre anlegen
- Überwachung des Postfachs in Monitor und /health/sync

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 11:29:26 +02:00
1 parent 0b7205e050
commit e5f9e0762f
33 files changed
+1450 -38

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Console\Commands;
use App\Actions\ProcessPortalMail;
use App\Channels\ChannelSyncException;
use App\Channels\Mail\MailboxReader;
use App\Models\Channel;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('channels:fetch-mail')]
#[Description('Read booking notifications of the portals from the mailbox and block recognised bookings immediately')]
class FetchPortalMail extends Command
{
/**
* Execute the console command.
*/
public function handle(MailboxReader $reader, ProcessPortalMail $processPortalMail): int
{
if (! MailboxReader::isConfigured()) {
$this->line('Kein Postfach konfiguriert (FEWO_MAILBOX_HOST).');
return self::SUCCESS;
}
$senders = Channel::query()->active()->get()
->flatMap(fn (Channel $channel): array => $processPortalMail->senders($channel))
->unique()
->values()
->all();
if ($senders === []) {
$this->line('Für kein Portal sind Absender hinterlegt.');
return self::SUCCESS;
}
try {
$mails = $reader->fetch($senders);
} catch (ChannelSyncException $exception) {
$this->error($exception->getMessage());
return self::FAILURE;
}
foreach ($mails as $mail) {
if ($record = $processPortalMail->handle($mail)) {
$this->info("{$record->channel->name}: {$record->type->getLabel()} → {$record->status->getLabel()} ({$record->subject})");
}
}
return self::SUCCESS;
}
}