Files
LarsandClaude Opus 5.5 dff9e2344e 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>
2026-11-03 13:39:20 +01:00

63 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Model;
/**
* A landlord's IMAP mailbox (v0.11, CH-05). Several may exist, one is active. "portal_only" reads the portals'
* booking notifications as before; "full" reads every message of a mailbox dedicated to guest communication.
*/
#[Fillable(['label', 'host', 'port', 'encryption', 'username', 'password', 'folder', 'address', 'mode', 'is_active', 'last_fetched_at'])]
#[Hidden(['password'])]
class Mailbox extends Model
{
use BelongsToTenant;
public const PORTAL_ONLY = 'portal_only';
public const FULL = 'full';
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'password' => 'encrypted',
'is_active' => 'boolean',
'port' => 'integer',
'last_fetched_at' => 'immutable_datetime',
];
}
public function readsEverything(): bool
{
return $this->mode === self::FULL;
}
/**
* Connection data in the form the reader expects, or null when it is not usable.
*
* @return array{host: string, port: int, encryption: string, username: string, password: ?string, folder: string}|null
*/
public function connection(): ?array
{
if (blank($this->host) || blank($this->username)) {
return null;
}
return [
'host' => (string) $this->host,
'port' => (int) ($this->port ?: 993),
'encryption' => (string) ($this->encryption ?: 'ssl'),
'username' => (string) $this->username,
'password' => $this->password,
'folder' => (string) ($this->folder ?: 'INBOX'),
];
}
}