]> git.mxchange.org Git - friendica-addons.git/commitdiff
Bluesky: Improve DID detection for custom PDS
authorMichael <heluecht@pirati.ca>
Sun, 1 Sep 2024 11:39:59 +0000 (11:39 +0000)
committerTobias Diekershoff <tobias@noreply.git.friendi.ca>
Mon, 2 Sep 2024 04:32:54 +0000 (06:32 +0200)
bluesky/bluesky.php

index 19466a420d24f7624b1f184cb7721f079b0658d3..101568c7e826c6695b16242cf8029e223e01a797 100644 (file)
@@ -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;
+       }
+
+       // Possibly a custom PDS. 
+       $did = bluesky_get_did_by_dns($handle);
+       if ($did != '') {
+               return $did;
        }
-       Logger::debug('Got DID by PDS call', ['handle' => $handle, 'did' => $data->did]);
-       return $data->did;
+       
+       return bluesky_get_did_by_wellknown($handle);
 }
 
 function bluesky_get_user_did(int $uid, bool $refresh = false): ?string