iCal-Regelanwendung bei Zeitstempelupdates erlauben und Dialogfehler anzeigen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m53s

This commit is contained in:
Lars committed 2026-10-29 16:25:29 +01:00
1 parent 678e15256d
commit a0497fcccd
5 files changed
+170 -8

No files matched your search

+20 -1
View File
@@ -50,7 +50,10 @@ public function handle(Channel $channel): array
$event = $events->get($block->external_uid);
if ($event && $block->ical_raw !== null && $channel->ical_analyzed_at !== null
&& $block->updated_at->greaterThan($channel->ical_analyzed_at) && $block->ical_raw !== $event['raw']) {
throw ValidationException::withMessages(['rules' => 'Der Importbestand hat sich seit der Vorschau geändert. Den Kalender erneut analysieren und die Vorschau prüfen.']);
if (! $this->hasEquivalentTimestampUpdate($channel, $block, $event)) {
throw ValidationException::withMessages(['rules' => 'Der Importbestand hat sich seit der Vorschau geändert. Den Kalender erneut analysieren und die Vorschau prüfen.']);
}
$event = [...$event, 'properties' => $block->ical_properties, 'raw' => $block->ical_raw];
}
$properties = $event['properties'] ?? $block->ical_properties;
if ($properties === null) {
@@ -69,4 +72,20 @@ public function handle(Channel $channel): array
return $counts;
});
}
private function hasEquivalentTimestampUpdate(Channel $channel, BlockedPeriod $block, array $event): bool
{
if ($block->ical_properties === null) {
return false;
}
$withoutTimestamps = fn (string $raw): string => preg_replace('/^(?:DTSTAMP|LAST-MODIFIED)(?:;[^:\r\n]*)?:[^\r\n]*(?:\r\n|\n|$)/mi', '', $raw);
if ($withoutTimestamps($block->ical_raw) !== $withoutTimestamps($event['raw'])) {
return false;
}
$engine = app(ICalRuleEngine::class);
return $engine->evaluate($channel, $block->ical_properties) === $engine->evaluate($channel, $event['properties']);
}
}
@@ -29,6 +29,7 @@
use Filament\Schemas\Schema;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException;
class ChannelRules extends EditRecord
{
@@ -183,14 +184,26 @@ protected function getHeaderActions(): array
}),
Action::make('applyRules')->label('Speichern & anwenden')->requiresConfirmation()
->modalDescription('Der Regelentwurf wird aktiviert und der vorhandene Kalenderbestand neu klassifiziert. IDs, Termine und persönliche Zuordnungen bleiben erhalten. Bekannte Herkunft beeinflusst den kanalspezifischen Export. Bei Namensfreigabe werden die gewählten Exportinformationen ebenfalls gespeichert.')
->action(function (ApplyChannelRules $apply): void {
$counts = DB::transaction(function () use ($apply): array {
$this->record = $this->handleRecordUpdate($this->record, $this->form->getState());
->action(function (ApplyChannelRules $apply, Action $action): void {
try {
$counts = DB::transaction(function () use ($apply): array {
$this->record = $this->handleRecordUpdate($this->record, $this->form->getState());
return $apply->handle($this->record);
});
return $apply->handle($this->record);
});
} catch (ValidationException $exception) {
$this->record->refresh();
$this->setErrorBag($exception->errors());
Notification::make()->title('Regeln wurden nicht angewendet')
->body(collect($exception->errors())->flatten()->unique()->implode(' '))
->danger()->persistent()->send();
$action->cancel();
}
$this->record->refresh();
Notification::make()->title($counts['classified'].' Einträge neu klassifiziert')->body($counts['missing_raw'].' Einträge ohne Originaldaten unverändert.')->success()->send();
$this->rememberData();
Notification::make()->title($counts['classified'].' Einträge neu klassifiziert')
->body($counts['missing_raw'].' Einträge ohne Originaldaten unverändert. Zeitgleiche Einträge anderer Kalender bleiben bis zur ausdrücklichen Zuordnung getrennt.')
->success()->send();
}),
Action::make('configuration')->label('Kalenderverbindung')->url(fn (): string => ChannelResource::getUrl('edit', ['record' => $this->record])),
];