- 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>
67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace App\Mail;
|
||
|
||
use App\Actions\RequestCaseData;
|
||
use App\Models\Booking;
|
||
use App\Models\DataRequest;
|
||
use App\Process\CaseRequirements;
|
||
use App\Support\Settings;
|
||
use Carbon\CarbonImmutable;
|
||
use Illuminate\Bus\Queueable;
|
||
use Illuminate\Mail\Mailable;
|
||
use Illuminate\Mail\Mailables\Address;
|
||
use Illuminate\Mail\Mailables\Content;
|
||
use Illuminate\Mail\Mailables\Envelope;
|
||
use Illuminate\Queue\SerializesModels;
|
||
|
||
/**
|
||
* The question for missing details (v0.11, S4): first question, targeted follow-up or reminder, with the guest's link.
|
||
* What it says about the dates follows the real state of the case at the moment of sending (CH §2a table): no hold,
|
||
* a clarification hold until its real end, an expired one, or a booking that is already binding – never the
|
||
* configured value. The guest may also simply answer the e-mail.
|
||
*/
|
||
class DataRequested extends Mailable
|
||
{
|
||
use Queueable, SerializesModels;
|
||
|
||
/** @var array{state: 'none'|'active'|'expired', until: ?CarbonImmutable} */
|
||
public array $clarification;
|
||
|
||
/** @var list<string> */
|
||
public array $missing;
|
||
|
||
public function __construct(public Booking $booking, public DataRequest $request, public string $kind, public string $url)
|
||
{
|
||
$this->clarification = $booking->clarificationState();
|
||
$this->missing = CaseRequirements::labels($request->fields);
|
||
}
|
||
|
||
public function envelope(): Envelope
|
||
{
|
||
$subject = $this->request->purpose === RequestCaseData::FOR_BOOKING ? 'Ihre Buchung '.$this->booking->reference : 'Ihre Anfrage '.$this->booking->reference;
|
||
|
||
return new Envelope(
|
||
subject: match ($this->kind) {
|
||
DataRequest::REMINDER => 'Erinnerung – '.$subject.': Es fehlen noch Angaben',
|
||
DataRequest::FOLLOWUP => $subject.': Noch eine kurze Rückfrage',
|
||
default => $subject.': Bitte ergänzen Sie Ihre Angaben',
|
||
},
|
||
// Answers go to the dedicated mailbox when one is read completely (v0.11 inbox), so they reach the case.
|
||
replyTo: [new Address(self::replyAddress(), config('fewo.owner.name'))],
|
||
);
|
||
}
|
||
|
||
public static function replyAddress(): string
|
||
{
|
||
$mailbox = Settings::tenant()?->activeMailbox();
|
||
|
||
return $mailbox?->readsEverything() && filled($mailbox->address) ? (string) $mailbox->address : (string) config('fewo.owner.email');
|
||
}
|
||
|
||
public function content(): Content
|
||
{
|
||
return new Content(markdown: 'mail.data-requested');
|
||
}
|
||
}
|