forked from friendica/friendica-addons
Compare commits
No commits in common. "fca2d609c910066540fefdbf747e86cf8ad82711" and "10bd219bd1658455e639a5dbd5555b8f589d48dc" have entirely different histories.
fca2d609c9
...
10bd219bd1
|
@ -139,7 +139,7 @@ function bluesky_probe_detect(array &$hookData)
|
|||
return;
|
||||
}
|
||||
} elseif (Network::isValidHttpUrl($hookData['uri'])) {
|
||||
$did = bluesky_get_did_by_profile($hookData['uri'], $pconfig['uid']);
|
||||
$did = bluesky_get_did_by_profile($hookData['uri']);
|
||||
if (empty($did)) {
|
||||
return;
|
||||
}
|
||||
|
@ -181,21 +181,21 @@ function bluesky_item_by_link(array &$hookData)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!preg_match('#/profile/(.+)/post/(.+)#', $hookData['uri'], $matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$did = bluesky_get_did($matches[1], $hookData['uid']);
|
||||
$did = bluesky_get_did_by_profile($hookData['uri']);
|
||||
if (empty($did)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
|
||||
if (!preg_match('#/profile/.+/post/(.+)#', $hookData['uri'], $matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
|
||||
Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[1]]);
|
||||
|
||||
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[1];
|
||||
|
||||
$uri = bluesky_fetch_missing_post($uri, $hookData['uid'], $hookData['uid'], Item::PR_FETCHED, 0, 0, 0);
|
||||
Logger::debug('Got post', ['did' => $did, 'cid' => $matches[2], 'result' => $uri]);
|
||||
Logger::debug('Got post', ['did' => $did, 'cid' => $matches[1], 'result' => $uri]);
|
||||
if (!empty($uri)) {
|
||||
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
|
||||
if (!empty($item['id'])) {
|
||||
|
@ -278,12 +278,14 @@ function bluesky_block(array &$hook_data)
|
|||
return;
|
||||
}
|
||||
|
||||
if ($hook_data['contact']['network'] != Protocol::BLUESKY) {
|
||||
Logger::debug('Check if contact is bluesky', ['data' => $hook_data]);
|
||||
$contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]);
|
||||
if (empty($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record = [
|
||||
'subject' => $hook_data['contact']['url'],
|
||||
'subject' => $contact['url'],
|
||||
'createdAt' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'$type' => 'app.bsky.graph.block'
|
||||
];
|
||||
|
@ -1295,7 +1297,6 @@ function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_ui
|
|||
// When "ver" is set to "1" it was flagged by some automated process.
|
||||
if (empty($label->ver)) {
|
||||
$item['sensitive'] = true;
|
||||
$item['content-warning'] = $label->val ?? '';
|
||||
Logger::debug('Sensitive content', ['uri-id' => $item['uri-id'], 'label' => $label]);
|
||||
}
|
||||
}
|
||||
|
@ -1831,14 +1832,8 @@ function bluesky_get_preferences(int $uid): ?stdClass
|
|||
return $data;
|
||||
}
|
||||
|
||||
function bluesky_get_did_by_profile(string $url, int $uid): string
|
||||
function bluesky_get_did_by_profile(string $url): string
|
||||
{
|
||||
if (preg_match('#/profile/(.+)#', $url, $matches)) {
|
||||
$did = bluesky_get_did($matches[1], $uid);
|
||||
if (!empty($did)) {
|
||||
return $did;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
|
||||
} catch (\Throwable $th) {
|
||||
|
@ -1947,6 +1942,13 @@ function bluesky_get_did(string $handle, int $uid): string
|
|||
return $did;
|
||||
}
|
||||
|
||||
// The profile page can contain hints to the DID as well
|
||||
$did = bluesky_get_did_by_profile('https://' . $handle);
|
||||
if ($did != '') {
|
||||
Logger::debug('Got DID by profile page', ['handle' => $handle, 'did' => $did]);
|
||||
return $did;
|
||||
}
|
||||
|
||||
// And finally we use the default PDS from Bluesky.
|
||||
$data = bluesky_get(BLUESKY_PDS . '/xrpc/com.atproto.identity.resolveHandle?handle=' . urlencode($handle));
|
||||
if (!empty($data) && !empty($data->did)) {
|
||||
|
|
Loading…
Reference in a new issue