diff --git a/app/Http/Controllers/Web/ContactController.php b/app/Http/Controllers/Web/ContactController.php index b8c9c9b2..4eb12c74 100644 --- a/app/Http/Controllers/Web/ContactController.php +++ b/app/Http/Controllers/Web/ContactController.php @@ -52,7 +52,13 @@ class ContactController extends Controller private function recipient(): string { - $brand = WebPortalContext::fromRequest()->domainConfig['brand'] ?? []; + // Auch die Hub-Domain (pressekonto) nutzt das Formular — sie ist kein + // Spoke-Portal, daher vor dem WebPortalContext am Host unterscheiden. + if (str_contains(request()->getHost(), 'pressekonto')) { + $brand = config('domains.domains.pressekonto.brand', []); + } else { + $brand = WebPortalContext::fromRequest()->domainConfig['brand'] ?? []; + } return $brand['contact_email'] ?? config('mail.from.address'); } diff --git a/tests/Feature/Web/ContactFormTest.php b/tests/Feature/Web/ContactFormTest.php index e3849759..79d5e367 100644 --- a/tests/Feature/Web/ContactFormTest.php +++ b/tests/Feature/Web/ContactFormTest.php @@ -50,6 +50,20 @@ test('without a configured brand address the mail falls back to the from address Mail::assertSent(ContactRequestSubmitted::class, fn (ContactRequestSubmitted $mail) => $mail->hasTo('fallback@pressekonto.de')); }); +test('a contact request from the hub domain goes to the pressekonto brand address', function () { + /** @var TestCase $this */ + Mail::fake(); + config()->set('domains.domains.pressekonto.brand.contact_email', 'kontakt@pressekonto.de'); + + $this->post('https://pressekonto.test/de/kontakt', [ + 'name' => 'Paula Presse', + 'email' => 'paula@example.test', + 'message' => 'Ich habe eine Frage zu Ihrer Plattform und bitte um Rückruf.', + ])->assertSessionHas('contact-status'); + + Mail::assertSent(ContactRequestSubmitted::class, fn (ContactRequestSubmitted $mail) => $mail->hasTo('kontakt@pressekonto.de')); +}); + test('honeypot submissions are silently accepted without sending mail', function () { /** @var TestCase $this */ Mail::fake();