- Connector-System (app/Channels, config/channels.php) mit iCal-Connector, robustem Parser und Export-Feed je Portal (ohne eigene Belegungen, ohne Gästedaten) - Abgleich alle 5 Min. mit Protokoll, Echo-Erkennung, Konflikt-Mail bei möglicher Doppelbuchung - Überwachung: Störungs-Mail, Status-Endpunkt /health/sync für n8n - Portal-Aufgaben für Sofortbuchungsportale (FeWo-direkt): automatisch aus Buchungen/Sperren/anderen Portalen, Mail + Erinnerung, Abhaken im Admin - Optionaler signierter Automatisierungs-Webhook mit Rückmeldung - Herkunftsmessung: Abfrage im Formular + UTM-Parameter - Portal-Analyse: AGB-Prüfung Automatisierung, Umsetzungsbeschreibung Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Channels\ICal;
|
|
|
|
use App\Channels\ChannelSyncException;
|
|
use App\Channels\Contracts\ChannelConnector;
|
|
use App\Models\Channel;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Illuminate\Http\Client\ConnectionException;
|
|
use Illuminate\Http\Client\RequestException;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
/**
|
|
* Generic calendar connection that works with almost every portal: we read the portal's iCal export
|
|
* and the portal reads our feed for this channel.
|
|
*/
|
|
class ICalConnector implements ChannelConnector
|
|
{
|
|
public function __construct(private ICalParser $parser) {}
|
|
|
|
public static function key(): string
|
|
{
|
|
return 'ical';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Kalender-Abgleich (iCal)';
|
|
}
|
|
|
|
public static function settingsSchema(): array
|
|
{
|
|
return [
|
|
TextInput::make('settings.import_url')
|
|
->label('iCal-Export-Adresse des Portals')
|
|
->helperText('Im Vermieterbereich des Portals unter „Kalender exportieren“. Leer lassen, wenn das Portal keinen Kalender anbietet.')
|
|
->url()
|
|
->maxLength(2048),
|
|
];
|
|
}
|
|
|
|
public function canImport(Channel $channel): bool
|
|
{
|
|
return filled($channel->setting('import_url'));
|
|
}
|
|
|
|
public function fetchOccupations(Channel $channel): array
|
|
{
|
|
$url = preg_replace('#^webcals?://#i', 'https://', (string) $channel->setting('import_url'));
|
|
|
|
try {
|
|
$response = Http::timeout(20)
|
|
->retry(2, 1000)
|
|
->withHeaders(['Accept' => 'text/calendar'])
|
|
->get($url)
|
|
->throw();
|
|
} catch (ConnectionException|RequestException $exception) {
|
|
throw new ChannelSyncException('Kalender konnte nicht abgerufen werden: '.$exception->getMessage(), previous: $exception);
|
|
}
|
|
|
|
return $this->parser->parse($response->body());
|
|
}
|
|
}
|