Merge platform registry into owned-domain picker lookups.
Deploy Ladill Servers / deploy (push) Successful in 28s
Deploy Ladill Servers / deploy (push) Successful in 28s
Fetch owned domains from both domains.ladill.com and the platform registry so legacy customer domains populate the Ladill picker. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -51,6 +51,7 @@ IDENTITY_API_KEY_SERVERS=
|
|||||||
DOMAINS_API_URL=https://domains.ladill.com/api
|
DOMAINS_API_URL=https://domains.ladill.com/api
|
||||||
DOMAINS_API_KEY_SERVERS=
|
DOMAINS_API_KEY_SERVERS=
|
||||||
|
|
||||||
|
DOMAIN_REGISTRY_API_URL=https://ladill.com/api
|
||||||
DOMAIN_API_URL=https://ladill.com/api/domains
|
DOMAIN_API_URL=https://ladill.com/api/domains
|
||||||
DOMAIN_API_KEY_SERVERS=
|
DOMAIN_API_KEY_SERVERS=
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,25 @@ namespace App\Services\Domains;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/** Read-only client for domains purchased on Ladill (storefront + platform registry). */
|
||||||
class LadillDomainsClient
|
class LadillDomainsClient
|
||||||
{
|
{
|
||||||
/** @return list<string> */
|
/** @return list<string> Active domain names owned by the account (lowercase). */
|
||||||
public function ownedForUser(string $publicId): array
|
public function ownedForUser(string $publicId): array
|
||||||
|
{
|
||||||
|
return collect()
|
||||||
|
->merge($this->fetchFromStorefront($publicId))
|
||||||
|
->merge($this->fetchFromPlatform($publicId))
|
||||||
|
->map(fn ($d) => strtolower(trim((string) $d)))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->sort()
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<string> */
|
||||||
|
private function fetchFromStorefront(string $publicId): array
|
||||||
{
|
{
|
||||||
$key = (string) (config('domains.api_key') ?? '');
|
$key = (string) (config('domains.api_key') ?? '');
|
||||||
if ($key === '') {
|
if ($key === '') {
|
||||||
@@ -25,13 +40,38 @@ class LadillDomainsClient
|
|||||||
|
|
||||||
$res->throw();
|
$res->throw();
|
||||||
|
|
||||||
return collect($res->json('data', []))
|
return (array) $res->json('data', []);
|
||||||
->map(fn ($d) => strtolower(trim((string) $d)))
|
|
||||||
->filter()
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('LadillDomainsClient: could not load owned domains', [
|
Log::warning('LadillDomainsClient: storefront owned domains unavailable', [
|
||||||
|
'user' => $publicId,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<string> */
|
||||||
|
private function fetchFromPlatform(string $publicId): array
|
||||||
|
{
|
||||||
|
$key = (string) (config('domains.platform_api_key') ?? '');
|
||||||
|
if ($key === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$res = Http::withToken($key)
|
||||||
|
->acceptJson()
|
||||||
|
->timeout(10)
|
||||||
|
->get(rtrim((string) config('domains.platform_api_url'), '/').'/owned-domains', [
|
||||||
|
'user' => $publicId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res->throw();
|
||||||
|
|
||||||
|
return (array) $res->json('data', []);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning('LadillDomainsClient: platform owned domains unavailable', [
|
||||||
'user' => $publicId,
|
'user' => $publicId,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -3,4 +3,7 @@
|
|||||||
return [
|
return [
|
||||||
'api_url' => env('DOMAINS_API_URL', 'https://domains.ladill.com/api'),
|
'api_url' => env('DOMAINS_API_URL', 'https://domains.ladill.com/api'),
|
||||||
'api_key' => env('DOMAINS_API_KEY_SERVERS'),
|
'api_key' => env('DOMAINS_API_KEY_SERVERS'),
|
||||||
|
|
||||||
|
'platform_api_url' => env('DOMAIN_REGISTRY_API_URL', 'https://ladill.com/api'),
|
||||||
|
'platform_api_key' => env('DOMAIN_API_KEY_SERVERS'),
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user