diff --git a/app/Services/Link/LinkPlatformProxy.php b/app/Services/Link/LinkPlatformProxy.php index 4864d0e..6408e20 100644 --- a/app/Services/Link/LinkPlatformProxy.php +++ b/app/Services/Link/LinkPlatformProxy.php @@ -27,6 +27,10 @@ class LinkPlatformProxy ); } + if ($this->isEventsRegistrationPath($normalizedPath)) { + return $this->forwardToQrHub($request, $slug, $normalizedPath, $this->eventsBaseUrl()); + } + $platformResponse = $this->forwardToQrHub($request, $slug, $normalizedPath, $this->platformBaseUrl()); if ($platformResponse->getStatusCode() !== 404) { return $platformResponse; @@ -107,6 +111,13 @@ class LinkPlatformProxy return $this->forward($request, $slug, substr($path, strlen($slugPrefix))); } + private function isEventsRegistrationPath(string $path): bool + { + return $path === 'register' + || str_starts_with($path, 'register/') + || str_starts_with($path, 'registered/'); + } + private function platformBaseUrl(): string { return rtrim((string) config('app.platform_url', 'https://ladill.com'), '/'); diff --git a/tests/Feature/LinkRedirectTest.php b/tests/Feature/LinkRedirectTest.php index 63ac79e..d2d12a1 100644 --- a/tests/Feature/LinkRedirectTest.php +++ b/tests/Feature/LinkRedirectTest.php @@ -123,4 +123,35 @@ class LinkRedirectTest extends TestCase && $request->hasHeader('X-Ladill-Internal', '1'); }); } + + public function test_event_registration_confirmation_proxies_directly_to_events_app(): void + { + $user = $this->user(); + ShortLink::create([ + 'user_id' => $user->id, + 'slug' => 'sales-webinar', + 'source_app' => 'events', + 'source_kind' => 'qr', + 'is_managed_here' => false, + 'destination_url' => 'https://ladl.link/sales-webinar', + 'is_active' => true, + ]); + + Http::fake([ + 'https://events.ladill.com/q/sales-webinar/registered/QRE-TESTREF123456' => Http::response('Registration confirmed', 200), + ]); + + $this->get('https://ladl.link/sales-webinar/registered/QRE-TESTREF123456') + ->assertOk() + ->assertSee('Registration confirmed'); + + Http::assertSent(function ($request) { + return $request->url() === 'https://events.ladill.com/q/sales-webinar/registered/QRE-TESTREF123456' + && $request->hasHeader('X-Ladill-Internal', '1'); + }); + + Http::assertNotSent(function ($request) { + return str_starts_with($request->url(), 'https://ladill.com/q/sales-webinar/registered/'); + }); + } }