Eindeutige iCal-Kalenderspiegelungen automatisch und widerrufbar zuordnen
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
8b36e07dc4
commit
add2367869
16 files changed
+540
-31
No files matched your search
+18
-15
@@ -95,21 +95,6 @@ public function handle(Channel $channel): ChannelSyncLog
|
||||
app(ApplyChannelRules::class)->store($block, [...$interpretation, 'ical_properties' => $period->properties, 'ical_raw' => $period->raw]);
|
||||
}
|
||||
$existing->put($period->uid, $block);
|
||||
$overlap = $channel->blockedPeriods()->occupying()->overlapping($block->starts_on, $block->ends_on)->whereKeyNot($block->id)->exists();
|
||||
$foundConflicts = $block->is_representation ? [] : $this->conflictDetector->conflictsFor($block);
|
||||
$linked = $block->canonicalBlock ?? $block->linkedBooking;
|
||||
$linkedStart = $linked instanceof Booking ? $linked->arrival : $linked?->starts_on;
|
||||
$linkedEnd = $linked instanceof Booking ? $linked->departure : $linked?->ends_on;
|
||||
$representationChanged = $block->is_representation && ($linked === null || ! $block->starts_on->equalTo($linkedStart) || ! $block->ends_on->equalTo($linkedEnd));
|
||||
if ($representationChanged || (! $block->is_representation && $block->reviewed_at === null && ($overlap || $emails->isNotEmpty() || $foundConflicts !== [] || ! $block->export_approved))) {
|
||||
$note = 'Mehrere Belegungsrepräsentationen oder Überschneidungen prüfen; keine automatische Zusammenführung anhand von Terminen.';
|
||||
$block->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
foreach ($emails as $mailBlock) {
|
||||
$mailBlock->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
}
|
||||
$warnings[] = $note;
|
||||
}
|
||||
array_push($conflicts, ...$foundConflicts);
|
||||
}
|
||||
$missing = $rows->filter(fn (BlockedPeriod $block): bool => ! $block->trashed() && ! isset($seen[$block->external_uid]) && $block->ends_on->greaterThan($today));
|
||||
if ($missing->count() > config('channels.max_automatic_removals', 5)) {
|
||||
@@ -128,6 +113,24 @@ public function handle(Channel $channel): ChannelSyncLog
|
||||
}
|
||||
}
|
||||
}
|
||||
app(ReconcileChannelRepresentations::class)->handle($channel->property);
|
||||
foreach ($channel->blockedPeriods()->with(['canonicalBlock', 'linkedBooking'])->where('source', 'channel')->whereIn('external_uid', array_keys($seen))->get() as $block) {
|
||||
$overlap = $channel->blockedPeriods()->occupying()->overlapping($block->starts_on, $block->ends_on)->whereKeyNot($block->id)->exists();
|
||||
$foundConflicts = $block->is_representation ? [] : $this->conflictDetector->conflictsFor($block);
|
||||
$linked = $block->canonicalBlock ?? $block->linkedBooking;
|
||||
$linkedStart = $linked instanceof Booking ? $linked->arrival : $linked?->starts_on;
|
||||
$linkedEnd = $linked instanceof Booking ? $linked->departure : $linked?->ends_on;
|
||||
$representationChanged = $block->is_representation && ($linked === null || ! $block->starts_on->equalTo($linkedStart) || ! $block->ends_on->equalTo($linkedEnd));
|
||||
if ($representationChanged || (! $block->is_representation && $block->reviewed_at === null && ($overlap || $emails->isNotEmpty() || $foundConflicts !== [] || ! $block->export_approved))) {
|
||||
$note = ReconcileChannelRepresentations::OVERLAP_NOTE;
|
||||
$block->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
foreach ($emails as $mailBlock) {
|
||||
$mailBlock->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
}
|
||||
$warnings[] = $note;
|
||||
}
|
||||
array_push($conflicts, ...$foundConflicts);
|
||||
}
|
||||
$warnings = array_values(array_unique($warnings));
|
||||
$locked->forceFill(['last_synced_at' => now(), 'last_success_at' => now(), 'last_error' => null,
|
||||
'alerted_at' => null, 'last_import_events' => count($periods), 'sync_warnings' => $warnings])->save();
|
||||
|
||||
Reference in new issue
Block a user