Files
LarsandClaude Sonnet 5.5 eafab8a2cb
Deploy FeWo mit PipelineManager / deploy (push) Failing after 3m38s
Buchungsprozess: Angebots-Snapshot, atomare Annahme, Auto-Angebot, Kanalfreigabe
- Angebotsbedingungen und Zahlungsdaten werden je Version eingefroren (offer_terms, offer_hash)
- Annahme in einer gesperrten Transaktion, idempotent, mit Nachweis; Mail- und Portalfehler
  machen eine gespeicherte Buchung nicht ungueltig (Postfach, Nachversand)
- Je Wohnung: manuelle/automatische Angebote, optionale Vorreservierung
- Automatische Freigabe abhaengig von aktuellen Importen und Feed-Abruf bei Sofortbuchungsportalen
- Deutsche Fehlerseiten, Buchungsseite zeigt Angebots- und Zustellstatus
- Dokumentation: BOOKING-E2E-*.md, BOOKING-COMPLIANCE-HANDOVER.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 12:01:02 +01:00

62 lines
2.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Support;
use App\Enums\InboxMessageKind;
use App\Models\Channel;
use App\Models\InboxMessage;
use Illuminate\Database\UniqueConstraintViolationException;
/**
* Posts findings to the admin inbox ("Postfach"). Each finding has a fingerprint and arrives only once
* per landlord, so a check that runs every few minutes does not report a lasting problem again and again.
* While the finding is still detected and the message is unread, it is repeated after the landlord's
* reminder interval (Settings::reminderIntervalDays(), 0 = never).
*/
class Inbox
{
/**
* @return InboxMessage|null the message to e-mail now – new (wasRecentlyCreated) or due for a reminder – else null
*/
public function post(InboxMessageKind $kind, string $fingerprint, string $subject, string $body, ?Channel $channel = null, ?string $actionUrl = null, ?int $propertyId = null): ?InboxMessage
{
$fingerprint = $kind->value.':'.$fingerprint;
$existing = InboxMessage::query()->where('fingerprint', $fingerprint)->first();
if ($existing) {
$due = $this->reminderDue($existing);
$existing->forceFill(['last_seen_at' => now(), ...($due ? ['notified_at' => now()] : [])])->save();
return $due ? $existing : null;
}
try {
return InboxMessage::create([
'kind' => $kind,
'fingerprint' => $fingerprint,
'subject' => mb_substr($subject, 0, 255),
'body' => $body,
'channel_id' => $channel?->id,
'property_id' => $channel?->property_id ?? $propertyId,
'action_url' => $actionUrl,
'notified_at' => now(),
'last_seen_at' => now(),
]);
} catch (UniqueConstraintViolationException) {
return null;
}
}
/**
* Unread messages are repeated once the reminder interval has passed; reading one ends its reminders.
*/
public function reminderDue(InboxMessage $message): bool
{
$days = Settings::reminderIntervalDays($message->tenant);
return $days > 0
&& ! $message->isRead()
&& ($message->notified_at === null || $message->notified_at->lessThanOrEqualTo(now()->subDays($days)));
}
}