Merge pull request 'Bluesky: Several improvements and fixes' (#1467) from heluecht/friendica-addons:bluesky into 2024.03-rc

Reviewed-on: https://git.friendi.ca/friendica/friendica-addons/pulls/1467
This commit is contained in:
Hypolite Petovan 2024-02-27 01:33:44 +01:00
commit de784bdc95

View file

@ -141,7 +141,7 @@ function bluesky_probe_detect(array &$hookData)
return; return;
} }
$hookData['result'] = bluesky_get_contact_fields($data, 0, false); $hookData['result'] = bluesky_get_contact_fields($data, 0, $pconfig['uid'], false);
$hookData['result']['baseurl'] = bluesky_get_pds($did); $hookData['result']['baseurl'] = bluesky_get_pds($did);
@ -183,7 +183,7 @@ function bluesky_item_by_link(array &$hookData)
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2]; $uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
$uri = bluesky_fetch_missing_post($uri, $hookData['uid'], $hookData['uid'], 0, 0); $uri = bluesky_fetch_missing_post($uri, $hookData['uid'], $hookData['uid'], Item::PR_FETCHED, 0, 0, 0);
Logger::debug('Got post', ['profile' => $matches[1], 'cid' => $matches[2], 'result' => $uri]); Logger::debug('Got post', ['profile' => $matches[1], 'cid' => $matches[2], 'result' => $uri]);
if (!empty($uri)) { if (!empty($uri)) {
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]); $item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
@ -942,7 +942,7 @@ function bluesky_fetch_timeline(int $uid, int $last_poll)
} }
foreach (array_reverse($data->feed) as $entry) { foreach (array_reverse($data->feed) as $entry) {
bluesky_process_post($entry->post, $uid, Item::PR_NONE, 0, $last_poll); bluesky_process_post($entry->post, $uid, $uid, Item::PR_NONE, 0, 0, $last_poll);
if (!empty($entry->reason)) { if (!empty($entry->reason)) {
bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid); bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid);
} }
@ -1012,28 +1012,28 @@ function bluesky_fetch_notifications(int $uid, int $last_poll)
$item['gravity'] = Item::GRAVITY_ACTIVITY; $item['gravity'] = Item::GRAVITY_ACTIVITY;
$item['body'] = $item['verb'] = Activity::LIKE; $item['body'] = $item['verb'] = Activity::LIKE;
$item['thr-parent'] = bluesky_get_uri($notification->record->subject); $item['thr-parent'] = bluesky_get_uri($notification->record->subject);
$item['thr-parent'] = bluesky_fetch_missing_post($item['thr-parent'], $uid, $uid, $item['contact-id'], 0, $last_poll); $item['thr-parent'] = bluesky_fetch_missing_post($item['thr-parent'], $uid, $uid, Item::PR_FETCHED, $item['contact-id'], 0, $last_poll);
if (!empty($item['thr-parent'])) { if (!empty($item['thr-parent'])) {
$data = Item::insert($item); $data = Item::insert($item);
Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} else { } else {
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
} }
break; break;
case 'repost': case 'repost':
$item = bluesky_get_header($notification, $uri, $uid, $uid); $item = bluesky_get_header($notification, $uri, $uid, $uid);
$item['gravity'] = Item::GRAVITY_ACTIVITY; $item['gravity'] = Item::GRAVITY_ACTIVITY;
$item['body'] = $item['verb'] = Activity::ANNOUNCE; $item['body'] = $item['verb'] = Activity::ANNOUNCE;
$item['thr-parent'] = bluesky_get_uri($notification->record->subject); $item['thr-parent'] = bluesky_get_uri($notification->record->subject);
$item['thr-parent'] = bluesky_fetch_missing_post($item['thr-parent'], $uid, $uid, $item['contact-id'], 0, $last_poll); $item['thr-parent'] = bluesky_fetch_missing_post($item['thr-parent'], $uid, $uid, Item::PR_FETCHED, $item['contact-id'], 0, $last_poll);
if (!empty($item['thr-parent'])) { if (!empty($item['thr-parent'])) {
$data = Item::insert($item); $data = Item::insert($item);
Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} else { } else {
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]); Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
} }
break; break;
case 'follow': case 'follow':
$contact = bluesky_get_contact($notification->author, $uid, $uid); $contact = bluesky_get_contact($notification->author, $uid, $uid);
@ -1041,18 +1041,21 @@ function bluesky_fetch_notifications(int $uid, int $last_poll)
break; break;
case 'mention': case 'mention':
$data = bluesky_process_post($notification, $uid, Item::PR_PUSHED, 0, $last_poll); $contact = bluesky_get_contact($notification->author, 0, $uid);
Logger::debug('Got mention', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); $result = bluesky_fetch_missing_post($uri, $uid, $uid, Item::PR_TO, $contact['id'], 0, $last_poll);
Logger::debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break; break;
case 'reply': case 'reply':
$data = bluesky_process_post($notification, $uid, Item::PR_PUSHED, 0, $last_poll); $contact = bluesky_get_contact($notification->author, 0, $uid);
Logger::debug('Got reply', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); $result = bluesky_fetch_missing_post($uri, $uid, $uid, Item::PR_COMMENT, $contact['id'], 0, $last_poll);
Logger::debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break; break;
case 'quote': case 'quote':
$data = bluesky_process_post($notification, $uid, Item::PR_PUSHED, 0, $last_poll); $contact = bluesky_get_contact($notification->author, 0, $uid);
Logger::debug('Got quote', ['uid' => $uid, 'result' => $data, 'uri' => $uri]); $result = bluesky_fetch_missing_post($uri, $uid, $uid, Item::PR_PUSHED, $contact['id'], 0, $last_poll);
Logger::debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break; break;
default: default:
@ -1090,15 +1093,12 @@ function bluesky_fetch_feed(int $uid, string $feed, int $last_poll)
Logger::debug('Unwanted language detected', ['text' => $entry->post->record->text]); Logger::debug('Unwanted language detected', ['text' => $entry->post->record->text]);
continue; continue;
} }
$id = bluesky_process_post($entry->post, $uid, Item::PR_TAG, 0, $last_poll); $uri_id = bluesky_process_post($entry->post, $uid, $uid, Item::PR_TAG, 0, 0, $last_poll);
if (!empty($id)) { if (!empty($uri_id)) {
$post = Post::selectFirst(['uri-id'], ['id' => $id]); $stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
if (!empty($post['uri-id'])) { Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
$stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl); } else {
Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]); Logger::notice('Post not found', ['entry' => $entry]);
} else {
Logger::notice('Post not found', ['id' => $id, 'entry' => $entry]);
}
} }
if (!empty($entry->reason)) { if (!empty($entry->reason)) {
bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid); bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid);
@ -1106,22 +1106,23 @@ function bluesky_fetch_feed(int $uid, string $feed, int $last_poll)
} }
} }
function bluesky_process_post(stdClass $post, int $uid, int $post_reason, int $level, int $last_poll): int function bluesky_process_post(stdClass $post, int $uid, int $fetch_uid, int $post_reason, int $causer, int $level, int $last_poll): int
{ {
$uri = bluesky_get_uri($post); $uri = bluesky_get_uri($post);
if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid])) { if ($uri_id = bluesky_fetch_uri_id($uri, $uid)) {
return $id['id']; return $uri_id;
} }
if ($id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) { if (empty($post->record)) {
return $id['id']; Logger::debug('Invalid post', ['uri' => $uri]);
return 0;
} }
Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']); Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']);
$item = bluesky_get_header($post, $uri, $uid, $uid); $item = bluesky_get_header($post, $uri, $uid, $fetch_uid);
$item = bluesky_get_content($item, $post->record, $uri, $uid, $uid, $level, $last_poll); $item = bluesky_get_content($item, $post->record, $uri, $uid, $fetch_uid, $level, $last_poll);
if (empty($item)) { if (empty($item)) {
return 0; return 0;
} }
@ -1134,13 +1135,18 @@ function bluesky_process_post(stdClass $post, int $uid, int $post_reason, int $l
$item['post-reason'] = $post_reason; $item['post-reason'] = $post_reason;
} }
return Item::insert($item); if ($causer != 0) {
$item['causer-id'] = $causer;
}
Item::insert($item);
return bluesky_fetch_uri_id($uri, $uid);
} }
function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_uid): array function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_uid): array
{ {
$parts = bluesky_get_uri_parts($uri); $parts = bluesky_get_uri_parts($uri);
if (empty($post->author)) { if (empty($post->author) || empty($post->cid) || empty($parts->rkey)) {
return []; return [];
} }
$contact = bluesky_get_contact($post->author, $uid, $fetch_uid); $contact = bluesky_get_contact($post->author, $uid, $fetch_uid);
@ -1181,7 +1187,7 @@ function bluesky_get_content(array $item, stdClass $record, string $uri, int $ui
if (!empty($record->reply)) { if (!empty($record->reply)) {
$item['parent-uri'] = bluesky_get_uri($record->reply->root); $item['parent-uri'] = bluesky_get_uri($record->reply->root);
if ($item['parent-uri'] != $uri) { if ($item['parent-uri'] != $uri) {
$item['parent-uri'] = bluesky_fetch_missing_post($item['parent-uri'], $uid, $fetch_uid, $item['contact-id'], $level, $last_poll); $item['parent-uri'] = bluesky_fetch_missing_post($item['parent-uri'], $uid, $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
if (empty($item['parent-uri'])) { if (empty($item['parent-uri'])) {
return []; return [];
} }
@ -1189,7 +1195,7 @@ function bluesky_get_content(array $item, stdClass $record, string $uri, int $ui
$item['thr-parent'] = bluesky_get_uri($record->reply->parent); $item['thr-parent'] = bluesky_get_uri($record->reply->parent);
if (!in_array($item['thr-parent'], [$uri, $item['parent-uri']])) { if (!in_array($item['thr-parent'], [$uri, $item['parent-uri']])) {
$item['thr-parent'] = bluesky_fetch_missing_post($item['thr-parent'], $uid, $fetch_uid, $item['contact-id'], $level, $last_poll, $item['parent-uri']); $item['thr-parent'] = bluesky_fetch_missing_post($item['thr-parent'], $uid, $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll, $item['parent-uri']);
if (empty($item['thr-parent'])) { if (empty($item['thr-parent'])) {
return []; return [];
} }
@ -1293,55 +1299,35 @@ function bluesky_add_media(stdClass $embed, array $item, int $fetch_uid, int $le
break; break;
case 'app.bsky.embed.record#view': case 'app.bsky.embed.record#view':
$uri = bluesky_get_uri($embed->record); $original_uri = $uri = bluesky_get_uri($embed->record);
$shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => $item['uid']]); $uri = bluesky_fetch_missing_post($uri, $item['uid'], $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
if (empty($shared)) { if ($uri) {
if (empty($embed->record->value)) { $shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$item['uid'], 0]]);
Logger::info('Record has got no value', ['record' => $embed->record]); $uri_id = $shared['uri-id'] ?? 0;
break;
}
$shared = bluesky_get_header($embed->record, $uri, 0, $fetch_uid);
$shared = bluesky_get_content($shared, $embed->record->value, $uri, $item['uid'], $fetch_uid, $level, $last_poll);
if (!empty($shared)) {
if (!empty($embed->record->embeds)) {
foreach ($embed->record->embeds as $single) {
$shared = bluesky_add_media($single, $shared, $fetch_uid, $level, $last_poll);
}
}
Item::insert($shared);
}
} }
if (!empty($shared['uri-id'])) { if (!empty($uri_id)) {
$item['quote-uri-id'] = $shared['uri-id']; $item['quote-uri-id'] = $uri_id;
} else {
Logger::debug('Quoted post could not be fetched', ['original-uri' => $original_uri, 'uri' => $uri]);
} }
break; break;
case 'app.bsky.embed.recordWithMedia#view': case 'app.bsky.embed.recordWithMedia#view':
$uri = bluesky_get_uri($embed->record->record); $original_uri = $uri = bluesky_get_uri($embed->record->record);
$shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => $item['uid']]); $uri = bluesky_fetch_missing_post($uri, $item['uid'], $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
if (empty($shared)) { if ($uri) {
$shared = bluesky_get_header($embed->record->record, $uri, 0, $fetch_uid); $shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$item['uid'], 0]]);
$shared = bluesky_get_content($shared, $embed->record->record->value, $uri, $item['uid'], $fetch_uid, $level, $last_poll); $uri_id = $shared['uri-id'] ?? 0;
if (!empty($shared)) {
if (!empty($embed->record->record->embeds)) {
foreach ($embed->record->record->embeds as $single) {
$shared = bluesky_add_media($single, $shared, $fetch_uid, $level, $last_poll);
}
}
Item::insert($shared);
}
} }
if (!empty($shared['uri-id'])) { if (!empty($uri_id)) {
$item['quote-uri-id'] = $shared['uri-id']; $item['quote-uri-id'] = $uri_id;
} } else {
Logger::debug('Quoted post could not be fetched', ['original-uri' => $original_uri, 'uri' => $uri]);
if (!empty($embed->media)) {
$item = bluesky_add_media($embed->media, $item, $fetch_uid, $level, $last_poll);
} }
break; break;
default: default:
Logger::notice('Unhandled embed type', ['type' => $embed->$type, 'embed' => $embed]); Logger::notice('Unhandled embed type', ['uri-id' => $item['uri-id'], 'type' => $embed->$type, 'embed' => $embed]);
break; break;
} }
return $item; return $item;
@ -1399,7 +1385,7 @@ function bluesky_get_uri_parts(string $uri): ?stdClass
return $class; return $class;
} }
function bluesky_fetch_missing_post(string $uri, int $uid, int $fetch_uid, int $causer, int $level, int $last_poll = 0, string $fallback = ''): string function bluesky_fetch_missing_post(string $uri, int $uid, int $fetch_uid, int $post_reason, int $causer, int $level, int $last_poll, string $fallback = ''): string
{ {
$fetched_uri = bluesky_fetch_post($uri, $uid); $fetched_uri = bluesky_fetch_post($uri, $uid);
if (!empty($fetched_uri)) { if (!empty($fetched_uri)) {
@ -1427,11 +1413,10 @@ function bluesky_fetch_missing_post(string $uri, int $uid, int $fetch_uid, int $
if ($causer != 0) { if ($causer != 0) {
$cdata = Contact::getPublicAndUserContactID($causer, $uid); $cdata = Contact::getPublicAndUserContactID($causer, $uid);
} else { $causer = $cdata['public'] ?? 0;
$cdata = [];
} }
return bluesky_process_thread($data->thread, $uid, $fetch_uid, $cdata, $level, $last_poll); return bluesky_process_thread($data->thread, $uid, $fetch_uid, $post_reason, $causer, $level, $last_poll);
} }
function bluesky_fetch_post(string $uri, int $uid): string function bluesky_fetch_post(string $uri, int $uid): string
@ -1449,7 +1434,22 @@ function bluesky_fetch_post(string $uri, int $uid): string
return ''; return '';
} }
function bluesky_process_thread(stdClass $thread, int $uid, int $fetch_uid, array $cdata, int $level, int $last_poll): string function bluesky_fetch_uri_id(string $uri, int $uid): string
{
$reply = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$uid, 0]]);
if (!empty($reply['uri-id'])) {
Logger::debug('Post with extid exists', ['uri' => $uri]);
return $reply['uri-id'];
}
$reply = Post::selectFirst(['uri-id'], ['extid' => $uri, 'uid' => [$uid, 0]]);
if (!empty($reply['uri-id'])) {
Logger::debug('Post with extid exists', ['uri' => $uri]);
return $reply['uri-id'];
}
return 0;
}
function bluesky_process_thread(stdClass $thread, int $uid, int $fetch_uid, int $post_reason, int $causer, int $level, int $last_poll): string
{ {
if (empty($thread->post)) { if (empty($thread->post)) {
Logger::info('Invalid post', ['post' => $thread]); Logger::info('Invalid post', ['post' => $thread]);
@ -1459,27 +1459,12 @@ function bluesky_process_thread(stdClass $thread, int $uid, int $fetch_uid, arra
$fetched_uri = bluesky_fetch_post($uri, $uid); $fetched_uri = bluesky_fetch_post($uri, $uid);
if (empty($fetched_uri)) { if (empty($fetched_uri)) {
Logger::debug('Process missing post', ['uri' => $uri]); $uri_id = bluesky_process_post($thread->post, $uid, $fetch_uid, $post_reason, $causer, $level, $last_poll);
$item = bluesky_get_header($thread->post, $uri, $uid, $uid); if ($uri_id) {
$item = bluesky_get_content($item, $thread->post->record, $uri, $uid, $fetch_uid, $level, $last_poll); Logger::debug('Post has been processed and stored', ['uri-id' => $uri_id, 'uri' => $uri]);
if (!empty($item)) { return $uri;
$item['post-reason'] = Item::PR_FETCHED;
if (!empty($cdata['public'])) {
$item['causer-id'] = $cdata['public'];
}
if (!empty($thread->post->embed)) {
$item = bluesky_add_media($thread->post->embed, $item, $uid, $level, $last_poll);
}
$id = Item::insert($item);
if (!$id) {
Logger::info('Item has not not been stored', ['uri' => $uri]);
return '';
}
Logger::debug('Stored item', ['id' => $id, 'uri' => $uri]);
} else { } else {
Logger::info('Post has not not been fetched', ['uri' => $uri]); Logger::info('Post has not not been stored', ['uri' => $uri]);
return ''; return '';
} }
} else { } else {
@ -1488,7 +1473,7 @@ function bluesky_process_thread(stdClass $thread, int $uid, int $fetch_uid, arra
} }
foreach ($thread->replies ?? [] as $reply) { foreach ($thread->replies ?? [] as $reply) {
$reply_uri = bluesky_process_thread($reply, $uid, $fetch_uid, $cdata, $level, $last_poll); $reply_uri = bluesky_process_thread($reply, $uid, $fetch_uid, Item::PR_FETCHED, $causer, $level, $last_poll);
Logger::debug('Reply has been processed', ['uri' => $uri, 'reply' => $reply_uri]); Logger::debug('Reply has been processed', ['uri' => $uri, 'reply' => $reply_uri]);
} }
@ -1502,7 +1487,7 @@ function bluesky_get_contact(stdClass $author, int $uid, int $fetch_uid): array
$update = empty($contact) || $contact['updated'] < DateTimeFormat::utc('now -24 hours'); $update = empty($contact) || $contact['updated'] < DateTimeFormat::utc('now -24 hours');
$public_fields = $fields = bluesky_get_contact_fields($author, $fetch_uid, $update); $public_fields = $fields = bluesky_get_contact_fields($author, $uid, $fetch_uid, $update);
$public_fields['uid'] = 0; $public_fields['uid'] = 0;
$public_fields['rel'] = Contact::NOTHING; $public_fields['rel'] = Contact::NOTHING;
@ -1543,8 +1528,9 @@ function bluesky_get_contact(stdClass $author, int $uid, int $fetch_uid): array
return Contact::getById($cid); return Contact::getById($cid);
} }
function bluesky_get_contact_fields(stdClass $author, int $uid, bool $update): array function bluesky_get_contact_fields(stdClass $author, int $uid, int $fetch_uid, bool $update): array
{ {
$nick = $author->handle ?? $author->did;
$fields = [ $fields = [
'uid' => $uid, 'uid' => $uid,
'network' => Protocol::BLUESKY, 'network' => Protocol::BLUESKY,
@ -1555,10 +1541,10 @@ function bluesky_get_contact_fields(stdClass $author, int $uid, bool $update): a
'pending' => false, 'pending' => false,
'url' => $author->did, 'url' => $author->did,
'nurl' => $author->did, 'nurl' => $author->did,
'alias' => BLUESKY_WEB . '/profile/' . $author->handle, 'alias' => BLUESKY_WEB . '/profile/' . $nick,
'name' => $author->displayName ?? $author->handle, 'name' => $author->displayName ?? $nick,
'nick' => $author->handle, 'nick' => $nick,
'addr' => $author->handle, 'addr' => $nick,
]; ];
if (!$update) { if (!$update) {
@ -1572,7 +1558,7 @@ function bluesky_get_contact_fields(stdClass $author, int $uid, bool $update): a
$fields['gsid'] = GServer::getID($fields['baseurl'], true); $fields['gsid'] = GServer::getID($fields['baseurl'], true);
} }
$data = bluesky_xrpc_get($uid, 'app.bsky.actor.getProfile', ['actor' => $author->did]); $data = bluesky_xrpc_get($fetch_uid, 'app.bsky.actor.getProfile', ['actor' => $author->did]);
if (empty($data)) { if (empty($data)) {
Logger::debug('Error fetching contact fields', ['uid' => $uid, 'url' => $fields['url']]); Logger::debug('Error fetching contact fields', ['uid' => $uid, 'url' => $fields['url']]);
return $fields; return $fields;
@ -1754,7 +1740,6 @@ function bluesky_xrpc_get(int $uid, string $url, array $parameters = []): ?stdCl
$data = bluesky_get(bluesky_get_user_pds($uid) . '/xrpc/' . $url, HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . bluesky_get_token($uid)]]]); $data = bluesky_get(bluesky_get_user_pds($uid) . '/xrpc/' . $url, HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . bluesky_get_token($uid)]]]);
DI::pConfig()->set($uid, 'bluesky', 'status', is_null($data) ? BLUEKSY_STATUS_API_FAIL : BLUEKSY_STATUS_SUCCESS); DI::pConfig()->set($uid, 'bluesky', 'status', is_null($data) ? BLUEKSY_STATUS_API_FAIL : BLUEKSY_STATUS_SUCCESS);
return $data; return $data;
} }
function bluesky_get(string $url, string $accept_content = HttpClientAccept::DEFAULT, array $opts = []): ?stdClass function bluesky_get(string $url, string $accept_content = HttpClientAccept::DEFAULT, array $opts = []): ?stdClass