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

+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Support;
use App\Enums\InboxMessageKind;
use App\Models\Channel;
use App\Models\InboxMessage;
use Illuminate\Database\UniqueConstraintViolationException;
/**
* Posts findings to the admin inbox ("Postfach"). Each finding has a fingerprint and arrives only once
* per landlord, so a check that runs every few minutes reports a lasting problem a single time.
*/
class Inbox
{
/**
* @return InboxMessage|null the new message, or null when this finding was posted before
*/
public function post(InboxMessageKind $kind, string $fingerprint, string $subject, string $body, ?Channel $channel = null, ?string $actionUrl = null): ?InboxMessage
{
$fingerprint = $kind->value.':'.$fingerprint;
if (InboxMessage::query()->where('fingerprint', $fingerprint)->exists()) {
return null;
}
try {
return InboxMessage::create([
'kind' => $kind,
'fingerprint' => $fingerprint,
'subject' => mb_substr($subject, 0, 255),
'body' => $body,
'channel_id' => $channel?->id,
'property_id' => $channel?->property_id,
'action_url' => $actionUrl,
]);
} catch (UniqueConstraintViolationException) {
return null;
}
}
}