From 50930c301d3d736fb204a69d1cafd778af819ca8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 1 Sep 2024 11:39:59 +0000 Subject: [PATCH] Bluesky: Improve DID detection for custom PDS --- bluesky/bluesky.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php index 19466a42..101568c7 100644 --- a/bluesky/bluesky.php +++ b/bluesky/bluesky.php @@ -1793,23 +1793,19 @@ function bluesky_get_did(string $handle): string $handle .= '.' . BLUESKY_HOSTNAME; } - // Deactivated at the moment, since it isn't reliable by now - //$did = bluesky_get_did_by_dns($handle); - //if ($did != '') { - // return $did; - //} - - //$did = bluesky_get_did_by_wellknown($handle); - //if ($did != '') { - // return $did; - //} - $data = bluesky_get(BLUESKY_PDS . '/xrpc/com.atproto.identity.resolveHandle?handle=' . urlencode($handle)); - if (empty($data) || empty($data->did)) { - return ''; + if (!empty($data) && !empty($data->did)) { + Logger::debug('Got DID by PDS call', ['handle' => $handle, 'did' => $data->did]); + return $data->did; } - Logger::debug('Got DID by PDS call', ['handle' => $handle, 'did' => $data->did]); - return $data->did; + + // Possibly a custom PDS. + $did = bluesky_get_did_by_dns($handle); + if ($did != '') { + return $did; + } + + return bluesky_get_did_by_wellknown($handle); } function bluesky_get_user_did(int $uid, bool $refresh = false): ?string