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

@@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use App\Enums\InboxMessageKind;
use App\Models\InboxMessage;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<InboxMessage>
*/
class InboxMessageFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'kind' => InboxMessageKind::ChannelConflict,
'fingerprint' => fake()->unique()->uuid(),
'subject' => fake()->sentence(4),
'body' => fake()->sentence(),
];
}
public function read(): static
{
return $this->state(fn (): array => ['read_at' => now()]);
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* The admin inbox: things the landlord has to look at. A fingerprint per landlord makes every
* finding (e.g. one possible double booking) arrive only once, however often it is detected.
*/
public function up(): void
{
Schema::create('inbox_messages', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->foreignId('property_id')->nullable()->constrained()->cascadeOnDelete();
$table->foreignId('channel_id')->nullable()->constrained()->nullOnDelete();
$table->string('kind');
$table->string('fingerprint', 100);
$table->string('subject');
$table->text('body');
$table->string('action_url')->nullable();
$table->timestamp('read_at')->nullable();
$table->timestamps();
$table->unique(['tenant_id', 'fingerprint']);
$table->index(['tenant_id', 'read_at']);
});
}
public function down(): void
{
Schema::dropIfExists('inbox_messages');
}
};