Compare commits

..
2 Commits
Author SHA1 Message Date
LarsandClaude Opus 5.5 f4a435c71a Vorgang: fehlende Angaben selbst eintragen als nächster Schritt
Deploy FeWo mit PipelineManager / deploy (push) Successful in 5m4s
- Wartet der Vorgang auf die Antwort des Gastes, ist „Fehlende Angaben
  selbst eintragen“ der große Schalter (vorher leer, Dialog nur unter
  „Weitere Möglichkeiten“). Die Eingabe läuft über den Fakteneingang
  (Herkunft „von Ihnen eingetragen“); die Rückfrage endet, sobald alles
  da ist, im Automatikmodus geht das Angebot hinaus.
- Dialog verständlicher benannt: „Gast eintragen“ / „Fehlende Angaben
  selbst eintragen“ / „Gastdaten bearbeiten“.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 17:31:51 +01:00
LarsandClaude Opus 5.5 154b8a434c Postfach: Posteingang wird unter jedem Namen gefunden; kein doppeltes „SSL“
- MailboxReader::folder(): „Posteingang“, „Inbox“ oder leer → INBOX (so
  heißt der Posteingang auf dem IMAP-Server); andere Namen ohne Beachtung
  der Groß-/Kleinschreibung; unbekannter Ordner → Meldung mit den
  vorhandenen Ordnern statt „Call to a member function query() on null“.
  Gilt für Portal-Abruf, vollständigen Abruf und „Postfach prüfen“.
- Verschlüsselung: Platzhalter „Standard (SSL)“ statt eines zweiten „SSL“;
  Hinweis am Ordnerfeld.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 17:26:49 +01:00
5 changed files with 84 additions and 8 deletions

No files matched your search

+27 -3
View File
@@ -7,7 +7,9 @@
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Cache;
use Throwable;
use Webklex\PHPIMAP\Client;
use Webklex\PHPIMAP\ClientManager;
use Webklex\PHPIMAP\Folder;
use Webklex\PHPIMAP\Message;
/**
@@ -70,7 +72,7 @@ public function fetch(array $senders): array
'protocol' => 'imap',
]);
$client->connect();
$folder = $client->getFolderByPath($config['folder']);
$folder = self::folder($client, $config['folder']);
$mails = [];
foreach ($senders as $sender) {
@@ -119,7 +121,7 @@ public function fetchAll(): array
'username' => $config['username'], 'password' => $config['password'], 'protocol' => 'imap',
]);
$client->connect();
$messages = $client->getFolderByPath($config['folder'])->query()
$messages = self::folder($client, $config['folder'])->query()
->whereSince(CarbonImmutable::today()->subDays((int) config('fewo.mailbox.lookback_days', 3)))
->leaveUnread()
->get();
@@ -156,7 +158,7 @@ public function probe(array $config): int
'username' => $config['username'], 'password' => $config['password'], 'protocol' => 'imap',
]);
$client->connect();
$count = $client->getFolderByPath($config['folder'])->query()
$count = self::folder($client, $config['folder'])->query()
->whereSince(CarbonImmutable::today()->subDays((int) config('fewo.mailbox.lookback_days', 3)))
->leaveUnread()->setFetchBody(false)->count();
$client->disconnect();
@@ -167,6 +169,28 @@ public function probe(array $config): int
return (int) $count;
}
/**
* The folder to read. The inbox is called "INBOX" on the IMAP server, whatever the provider's web mail shows
* ("Posteingang", "Inbox"); other names match regardless of case. An unknown name names the existing folders.
*
* @throws ChannelSyncException
*/
public static function folder(Client $client, ?string $name): Folder
{
$name = trim((string) $name);
$wanted = $name === '' || in_array(mb_strtolower($name), ['inbox', 'posteingang'], true) ? 'INBOX' : $name;
$folders = $client->getFolders(false);
$folder = $folders->first(fn (Folder $folder): bool => $folder->path === $wanted)
?? $folders->first(fn (Folder $folder): bool => mb_strtolower($folder->path) === mb_strtolower($wanted) || mb_strtolower($folder->name) === mb_strtolower($wanted));
if ($folder === null) {
throw new ChannelSyncException('Ordner „'.$name.'“ gibt es in diesem Postfach nicht. Vorhanden: '.$folders->map(fn (Folder $folder): string => $folder->path)->implode(', ').' (der Posteingang heißt „INBOX“).');
}
return $folder;
}
private function toPortalMail(Message $message): PortalMail
{
$text = $message->getTextBody();
+3 -2
View File
@@ -254,8 +254,9 @@ public function form(Schema $schema): Schema
Select::make('mailbox_encryption')
->label('Verschlüsselung')
->options(['ssl' => 'SSL', 'tls' => 'TLS', 'starttls' => 'STARTTLS'])
->placeholder('SSL'),
TextInput::make('mailbox_folder')->label('Ordner')->placeholder('INBOX')->maxLength(190),
->placeholder('Standard (SSL)'),
TextInput::make('mailbox_folder')->label('Ordner')->placeholder('INBOX')->maxLength(190)
->helperText('Leer lassen für den Posteingang (auf dem Server „INBOX“, auch „Posteingang“ wird erkannt).'),
Select::make('mailbox_mode')->label('Was wird gelesen?')
->options([Mailbox::PORTAL_ONLY => 'Nur Buchungsmails der Portale (wie bisher)', Mailbox::FULL => 'Alle Nachrichten (eigenes Postfach für die Gästekommunikation)'])
->required()
@@ -153,7 +153,9 @@ protected function getHeaderActions(): array
$this->setStatusAction(),
])->keyBy(fn (Action $action): string => $action->getName());
$next = CaseActivities::next($this->record)?->action;
// While the case waits for the guest's missing details, entering them oneself (call, other mail) is the step at hand.
$next = CaseActivities::next($this->record)?->action
?? collect(CaseActivities::for($this->record))->first(fn ($activity): bool => $activity->key === 'contact' && $activity->action !== null)?->action;
$primary = $next !== null && $actions->has($next) ? $actions->pull($next)->color('primary')->size('lg')->icon(Heroicon::OutlinedArrowRightCircle) : null;
$expert = $actions->only(self::EXPERT)->values()->all();
$more = $actions->except(self::EXPERT)->values()->all();
@@ -293,11 +295,15 @@ private function templateFields(): array
private function provideContactAction(): Action
{
return Action::make('provideContact')
->label(fn (): string => $this->record->guest === null ? 'Gast eintragen' : 'Kontaktdaten eintragen')
->label(fn (): string => match (true) {
$this->record->guest === null => 'Gast eintragen',
RequestCaseData::needs($this->record) !== null => 'Fehlende Angaben selbst eintragen',
default => 'Gastdaten bearbeiten',
})
->icon(Heroicon::OutlinedUserPlus)
->visible(fn (): bool => $this->record->internal_kind !== InternalKind::Block && ! in_array($this->record->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true))
->modalHeading('Kontaktdaten des Gastes')
->modalDescription(fn (): string => 'Aus Portalnachricht, E-Mail oder Telefonat. Nur eintragen, was bekannt ist.'.$this->openFactConflicts())
->modalDescription(fn (): string => 'Aus Telefonat, E-Mail, Portalnachricht oder Gespräch. Nur eintragen, was bekannt ist; Ihre Eingabe gilt und wird mit Herkunft „von Ihnen eingetragen“ festgehalten. Eine laufende Rückfrage endet, sobald alles da ist.'.$this->openFactConflicts())
->modalWidth('3xl')
->fillForm(fn (): array => [
'guest' => $this->record->guest?->only(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'country']) ?? [],
+21
View File
@@ -4,11 +4,13 @@
use App\Actions\ContributeCaseFacts;
use App\Actions\CreateReservation;
use App\Actions\ProvideGuestContact;
use App\Actions\RequestCaseData;
use App\Actions\TakeOverExternalBooking;
use App\Enums\BookingStatus;
use App\Enums\BookingTaskKind;
use App\Enums\FactSource;
use App\Filament\Resources\Bookings\Pages\ViewBooking;
use App\Mail\DataRequested;
use App\Mail\ReservationReceived;
use App\Models\Booking;
@@ -17,6 +19,7 @@
use App\Models\Channel;
use App\Models\DataRequest;
use App\Models\Property;
use App\Models\User;
use App\Pricing\StayRequest;
use App\Process\CaseActivities;
use App\Support\Content;
@@ -24,11 +27,13 @@
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Database\Seeders\SiteSeeder;
use Filament\Actions\Testing\TestAction;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Livewire\Livewire;
use Tests\TestCase;
/**
@@ -101,6 +106,22 @@ public function test_the_offer_waits_for_the_answer_even_when_the_steps_are_rele
$this->assertSame(BookingStatus::Reserved, $booking->fresh()->status, 'manual processing: nothing sent by itself');
}
public function test_the_landlord_enters_the_missing_details_himself_while_the_guest_is_asked(): void
{
$this->actingAs(User::factory()->create());
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic', 'data_request_mode' => 'automatic']]);
$booking = $this->request();
$page = Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()]);
$primary = $page->instance()->getCachedHeaderActions()[0];
$this->assertSame(['provideContact', 'Fehlende Angaben selbst eintragen'], [$primary->getName(), $primary->getLabel()]);
$page->callAction(TestAction::make('provideContact')->arguments([]), ['guest' => ['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => 'gesa@example.org', 'street' => 'Strandweg 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'], 'process' => ProvideGuestContact::AUTOMATIC, 'guest_confirmed' => false]);
$this->assertSame(DataRequest::COMPLETED, $booking->dataRequests()->first()->status);
$this->assertSame(BookingStatus::OfferSent, $booking->fresh()->status);
}
public function test_manual_mode_leaves_the_question_to_the_landlord(): void
{
Settings::tenant()->update(['process_defaults' => ['data_request_mode' => 'manual']]);
+24
View File
@@ -35,6 +35,9 @@
use Livewire\Livewire;
use Mockery;
use Tests\TestCase;
use Webklex\PHPIMAP\Client;
use Webklex\PHPIMAP\Folder;
use Webklex\PHPIMAP\Support\FolderCollection;
/**
* v0.11 package U5: the inbox of the guest communication mailbox – stored once, portal notifications through the
@@ -200,6 +203,27 @@ public function test_the_mailbox_can_be_checked_and_incoming_mails_show_on_the_c
->assertSee('Frage zu '.$booking->reference);
}
public function test_the_inbox_is_found_under_its_web_mail_name_and_an_unknown_folder_is_explained(): void
{
$folder = function (string $path): Folder {
$folder = Mockery::mock(Folder::class);
$folder->path = $path;
$folder->name = $path;
return $folder;
};
$client = Mockery::mock(Client::class);
$client->shouldReceive('getFolders')->andReturn(FolderCollection::make([$folder('Trash'), $folder('Sent Items'), $folder('INBOX')]));
foreach (['Posteingang', '', 'inbox', 'INBOX'] as $name) {
$this->assertSame('INBOX', MailboxReader::folder($client, $name)->path);
}
$this->assertSame('Sent Items', MailboxReader::folder($client, 'sent items')->path);
$this->expectExceptionMessage('Vorhanden: Trash, Sent Items, INBOX');
MailboxReader::folder($client, 'Archiv');
}
private function request(string $arrival = '2026-11-07', string $departure = '2026-11-10'): Booking
{
return app(CreateReservation::class)->handle($this->property->fresh(), new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2), ['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => 'gesa@example.org'])->fresh();