Doppelbuchungen nur einmal melden und im Postfach der Verwaltung zeigen

Der Kalenderabgleich alle 5 Minuten hat jede fortbestehende Ueberschneidung
erneut gemailt. ReportChannelConflicts legt jede Ueberschneidung einmal im
neuen Postfach (InboxMessage, Fingerabdruck je Mandant) ab und mailt nur neue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-10-30 09:52:35 +01:00
1 parent 876a0a20f3
commit b9225f5fb8
17 files changed
+593 -15

No files matched your search

+5 -8
View File
@@ -6,17 +6,14 @@
use App\Channels\ConflictDetector;
use App\Channels\ExternalPeriod;
use App\Enums\ChannelEchoBehavior;
use App\Mail\ChannelConflict;
use App\Models\BlockedPeriod;
use App\Models\Booking;
use App\Models\Channel;
use App\Models\ChannelSyncLog;
use App\Models\Property;
use App\Support\Settings;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
/** Imports one complete channel snapshot without guessing that overlapping events are identical. */
class SyncChannel
@@ -129,18 +126,18 @@ public function handle(Channel $channel): ChannelSyncLog
}
$warnings[] = $note;
}
array_push($conflicts, ...$foundConflicts);
foreach ($foundConflicts as $conflict) {
$conflicts[$conflict] ??= $block->starts_on;
}
}
$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();
});
if ($conflicts !== []) {
rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new ChannelConflict($channel, array_values(array_unique($conflicts)))));
}
app(ReportChannelConflicts::class)->handle($channel, $conflicts);
return $channel->syncLogs()->create(['successful' => true, 'events' => count($periods), ...$counts,
'conflicts' => count(array_unique($conflicts)), 'warnings' => $warnings,
'conflicts' => count($conflicts), 'warnings' => $warnings,
'duration_ms' => (int) round((microtime(true) - $startedAt) * 1000)]);
} catch (ChannelSyncException $exception) {
$channel->forceFill(['last_synced_at' => now(), 'last_error_at' => now(), 'last_error' => $exception->getMessage()])->save();