$id = bluesky_process_post($entry->post, $uid, Item::PR_TAG, 0);
if (!empty($id)) {
$post = Post::selectFirst(['uri-id'], ['id' => $id]);
- $stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
- Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
+ if (!empty($post['uri-id'])) {
+ $stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
+ Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
+ } else {
+ Logger::notice('Post not found', ['id' => $id, 'entry' => $entry]);
+ }
}
if (!empty($entry->reason)) {
bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid);
{
$uri = bluesky_get_uri($post);
- if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid]) || $id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) {
- return $id;
+ if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid])) {
+ return $id['id'];
+ }
+
+ if ($id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) {
+ return $id['id'];
}
Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']);
function bluesky_get_text(stdClass $record): string
{
- $text = $record->text;
+ $text = $record->text ?? '';
if (empty($record->facets)) {
return $text;
$shared = bluesky_add_media($single, $shared, $fetch_uid, $level);
}
}
- $id = Item::insert($shared);
- $shared = Post::selectFirst(['uri-id'], ['id' => $id]);
+ Item::insert($shared);
}
}
- if (!empty($shared)) {
+ if (!empty($shared['uri-id'])) {
$item['quote-uri-id'] = $shared['uri-id'];
}
break;
$shared = bluesky_add_media($single, $shared, $fetch_uid, $level);
}
}
-
- $id = Item::insert($shared);
- $shared = Post::selectFirst(['uri-id'], ['id' => $id]);
+ Item::insert($shared);
}
}
- if (!empty($shared)) {
+ if (!empty($shared['uri-id'])) {
$item['quote-uri-id'] = $shared['uri-id'];
}
function bluesky_process_thread(stdClass $thread, int $uid, array $cdata, int $level): string
{
+ if (empty($thread->post)) {
+ Logger::info('Invalid post', ['post' => $thread, 'callstack' => System::callstack(10, 0, true)]);
+ return '';
+ }
$uri = bluesky_get_uri($thread->post);
+
$fetched_uri = bluesky_fetch_post($uri, $uid);
if (empty($fetched_uri)) {
Logger::debug('Process missing post', ['uri' => $uri]);