iCal-Regelanwendung bei Zeitstempelupdates erlauben und Dialogfehler anzeigen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m53s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m53s
This commit is contained in:
1 parent
678e15256d
commit
a0497fcccd
5 files changed
+170
-8
No files matched your search
@@ -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']);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user