const BLUESKY_DIRECTORY = 'https://plc.directory'; // Path to the directory server service to fetch the PDS of a given DID
const BLUESKY_PDS = 'https://bsky.social'; // Path to the personal data server service (PDS) to fetch the DID for a given handle
const BLUESKY_WEB = 'https://bsky.app'; // Path to the web interface with the user profile and posts
+const BLUESKY_HOSTNAME = 'bsky.social'; // Host name to be added to the handle if incomplete
function bluesky_install()
{
{
$type = '$type';
$preferences = bluesky_get_preferences($uid);
+ if (empty($preferences) || empty($preferences->preferences)) {
+ return [];
+ }
foreach ($preferences->preferences as $preference) {
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPref') {
return $preference->pinned ?? [];
return [];
}
-function bluesky_get_preferences(int $uid): stdClass
+function bluesky_get_preferences(int $uid): ?stdClass
{
$cachekey = 'bluesky:preferences:' . $uid;
$data = DI::cache()->get($cachekey);
}
$data = bluesky_xrpc_get($uid, 'app.bsky.actor.getPreferences');
+ if (empty($data)) {
+ return null;
+ }
DI::cache()->set($cachekey, $data, Duration::HOUR);
return $data;
function bluesky_get_did(string $handle): string
{
+ if ($handle == '') {
+ return '';
+ }
+
+ if (strpos($handle, '.') === false) {
+ $handle .= '.' . BLUESKY_HOSTNAME;
+ }
+
// Deactivated at the moment, since it isn't reliable by now
//$did = bluesky_get_did_by_dns($handle);
//if ($did != '') {