v0.11 U5: Posteingang, deterministische Zuordnung, Klärungsansicht
- mailboxes (Modell für mehrere, eines aktiv): Übernahme des bisherigen Postfachs als „nur Portal-Mails“; Modus „alle Nachrichten“ für ein eigenes Postfach; Adresse als Antwortadresse der Rückfragen. - inbound_messages: jede Nachricht zuerst gespeichert, einmal je Message-ID, mit Testbetriebs-Kennzeichen (M10). Portal-Mails laufen unverändert über den Portalpfad (CH-08). - MessageMatcher (CH-13, ohne Scoring): Antwortbezug; Vorgangsnummer nur mit dem Gast als Absender; sonst Absender + Wohnung + beide Termine eines einzigen offenen Vorgangs. Ein offener Vorgang des Absenders allein genügt nicht (nur Hinweis). Alles andere → Klärung (M04). - Ausgehende Mails speichern ihre Message-ID; Antwort stoppt Erinnerungen. - Filament „Posteingang“: lesen, Vorgang zuordnen, als neue Anfrage anlegen, ignorieren, erledigt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4a3cb7f7b
commit
dff9e2344e
19 files changed
+990
-59
No files matched your search
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Prozessarchitektur v0.11, communication handler inbox (CH-01, CH-05, CH-06):
|
||||
*
|
||||
* - mailboxes: the data model allows several per landlord; at go-live one is active. Mode "portal_only" reads only the
|
||||
* portals' senders as before; "full" reads every message of a dedicated mailbox. The existing mailbox of each
|
||||
* landlord is taken over unchanged as "portal_only" (the tenant columns stay readable until production migrated).
|
||||
* - inbound_messages: every message read in "full" mode, stored before it is processed, deduplicated per landlord by
|
||||
* its Message-ID, with the case it was assigned to (or why it waits for clarification) and the test-mode mark.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('mailboxes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->string('label')->default('Postfach');
|
||||
$table->string('host', 190)->nullable();
|
||||
$table->unsignedSmallInteger('port')->nullable();
|
||||
$table->string('encryption', 10)->nullable();
|
||||
$table->string('username', 190)->nullable();
|
||||
$table->text('password')->nullable();
|
||||
$table->string('folder', 190)->nullable();
|
||||
$table->string('address')->nullable();
|
||||
$table->string('mode', 20)->default('portal_only');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->dateTime('last_fetched_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
foreach (DB::table('tenants')->whereNotNull('mailbox_host')->get() as $tenant) {
|
||||
DB::table('mailboxes')->insert([
|
||||
'tenant_id' => $tenant->id,
|
||||
'label' => 'Postfach',
|
||||
'host' => $tenant->mailbox_host,
|
||||
'port' => $tenant->mailbox_port,
|
||||
'encryption' => $tenant->mailbox_encryption,
|
||||
'username' => $tenant->mailbox_username,
|
||||
// Same application key, same encrypted value.
|
||||
'password' => $tenant->mailbox_password,
|
||||
'folder' => $tenant->mailbox_folder,
|
||||
'mode' => 'portal_only',
|
||||
'is_active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
Schema::create('inbound_messages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('mailbox_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('message_id');
|
||||
$table->string('in_reply_to')->nullable();
|
||||
$table->text('references')->nullable();
|
||||
$table->string('from_address')->nullable();
|
||||
$table->string('from_name')->nullable();
|
||||
$table->text('to_addresses')->nullable();
|
||||
$table->string('subject', 500)->nullable();
|
||||
$table->longText('body')->nullable();
|
||||
$table->dateTime('received_at');
|
||||
$table->boolean('test_mode')->default(false);
|
||||
$table->string('status', 20);
|
||||
$table->foreignId('booking_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('match_reason', 40)->nullable();
|
||||
$table->json('hints')->nullable();
|
||||
$table->unsignedBigInteger('portal_email_id')->nullable();
|
||||
$table->string('extraction_status', 20)->nullable();
|
||||
$table->json('extraction')->nullable();
|
||||
$table->dateTime('processed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'message_id']);
|
||||
$table->index(['status', 'extraction_status']);
|
||||
});
|
||||
|
||||
Schema::table('portal_emails', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('inbound_message_id')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('portal_emails', function (Blueprint $table) {
|
||||
$table->dropColumn('inbound_message_id');
|
||||
});
|
||||
Schema::dropIfExists('inbound_messages');
|
||||
Schema::dropIfExists('mailboxes');
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user