From c3fa39a053fc80044fe7ff974aab8c70876e033d Mon Sep 17 00:00:00 2001 From: isaacclad Date: Fri, 26 Jun 2026 20:16:57 +0000 Subject: [PATCH] Surface connected domains in Ladill Domains' My Domains Push the customer's connected domain to the central connected-domains registry so it appears under My Domains (with Transfer in if not registered with Ladill). Co-Authored-By: Claude Opus 4.8 --- .../Events/CustomDomainController.php | 16 ++++++++- .../CustomDomain/DomainsSslClient.php | 33 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Events/CustomDomainController.php b/app/Http/Controllers/Events/CustomDomainController.php index 741eed5..65d831f 100644 --- a/app/Http/Controllers/Events/CustomDomainController.php +++ b/app/Http/Controllers/Events/CustomDomainController.php @@ -6,12 +6,16 @@ use App\Http\Controllers\Controller; use App\Models\CustomDomain; use App\Models\QrCode; use App\Services\CustomDomain\CustomDomainService; +use App\Services\CustomDomain\DomainsSslClient; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; class CustomDomainController extends Controller { - public function __construct(private readonly CustomDomainService $service) {} + public function __construct( + private readonly CustomDomainService $service, + private readonly DomainsSslClient $domains, + ) {} public function store(Request $request, QrCode $event): RedirectResponse { @@ -31,6 +35,14 @@ class CustomDomainController extends Controller $this->service->attach($event, $host, (bool) ($data['include_www'] ?? true)); + // Surface this domain in Ladill Domains' "My Domains" (best-effort). + $this->domains->registerConnected( + $host, + (string) $request->user()->public_id, + 'Event: '.$event->label, + route('events.show', $event), + ); + return back()->with('success', "Domain added. Point an A record for {$host} (and www) to ".config('customdomain.server_ip').', then click Verify.'); } @@ -47,7 +59,9 @@ class CustomDomainController extends Controller { $this->authorize('update', $customDomain->qrCode); + $host = $customDomain->host; $customDomain->delete(); + $this->domains->removeConnected($host); return back()->with('success', 'Custom domain removed.'); } diff --git a/app/Services/CustomDomain/DomainsSslClient.php b/app/Services/CustomDomain/DomainsSslClient.php index 93237ca..8000df7 100644 --- a/app/Services/CustomDomain/DomainsSslClient.php +++ b/app/Services/CustomDomain/DomainsSslClient.php @@ -49,4 +49,37 @@ class DomainsSslClient return false; } } + + /** Register/update this domain in Ladill Domains' connected-domains registry (best-effort). */ + public function registerConnected(string $host, string $ownerPublicId, ?string $label = null, ?string $linkUrl = null): void + { + if (! $this->configured() || $ownerPublicId === '') { + return; + } + try { + Http::withToken((string) config('customdomain.ssl_api_key'))->acceptJson()->timeout(10) + ->post(config('customdomain.ssl_api_url').'/connected-domains', array_filter([ + 'host' => $host, + 'owner_public_id' => $ownerPublicId, + 'label' => $label, + 'link_url' => $linkUrl, + ])); + } catch (\Throwable $e) { + Log::info('DomainsSslClient: connected register skipped', ['host' => $host, 'error' => $e->getMessage()]); + } + } + + /** Remove this domain from the connected-domains registry (best-effort). */ + public function removeConnected(string $host): void + { + if (! $this->configured()) { + return; + } + try { + Http::withToken((string) config('customdomain.ssl_api_key'))->acceptJson()->timeout(10) + ->delete(config('customdomain.ssl_api_url').'/connected-domains/'.urlencode($host)); + } catch (\Throwable $e) { + Log::info('DomainsSslClient: connected remove skipped', ['host' => $host, 'error' => $e->getMessage()]); + } + } }