- 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>
73 lines
2.3 KiB
PHP
73 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* A message read from the landlord's mailbox (v0.11, S2/S3), stored before anything is done with it. It is assigned
|
|
* to a case only by a reliable reference (CH-13); otherwise it waits in the inbox for the landlord. Being assigned is
|
|
* not yet permission to take anything over.
|
|
*/
|
|
#[Fillable(['mailbox_id', 'message_id', 'in_reply_to', 'references', 'from_address', 'from_name', 'to_addresses', 'subject', 'body', 'received_at', 'test_mode', 'status', 'booking_id', 'match_reason', 'hints', 'portal_email_id', 'extraction_status', 'extraction', 'processed_at'])]
|
|
class InboundMessage extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
public const NEW = 'new';
|
|
|
|
/** Assigned to a case by a reliable reference. */
|
|
public const ASSIGNED = 'assigned';
|
|
|
|
/** Waits for the landlord: no or no reliable reference, or contradicting hints. */
|
|
public const NEEDS_REVIEW = 'needs_review';
|
|
|
|
/** A portal notification, handled by the existing portal path. */
|
|
public const PORTAL = 'portal';
|
|
|
|
public const IGNORED = 'ignored';
|
|
|
|
/** Done: details taken over or decided by the landlord. */
|
|
public const PROCESSED = 'processed';
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'body' => 'encrypted',
|
|
'references' => 'array',
|
|
'to_addresses' => 'array',
|
|
'hints' => 'array',
|
|
'extraction' => 'array',
|
|
'test_mode' => 'boolean',
|
|
'received_at' => 'immutable_datetime',
|
|
'processed_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Booking, $this>
|
|
*/
|
|
public function booking(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Booking::class);
|
|
}
|
|
|
|
public function statusLabel(): string
|
|
{
|
|
return match ($this->status) {
|
|
self::ASSIGNED => 'einem Vorgang zugeordnet',
|
|
self::NEEDS_REVIEW => 'zu klären',
|
|
self::PORTAL => 'Portal-Mail',
|
|
self::IGNORED => 'ignoriert',
|
|
self::PROCESSED => 'erledigt',
|
|
default => 'neu',
|
|
};
|
|
}
|
|
}
|