$data = Item::insert($item);
Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} 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;
return;
}
+ $feeddata = bluesky_xrpc_get($uid, 'app.bsky.feed.getFeedGenerator', ['feed' => $feed]);
+ if (!empty($feeddata)) {
+ $feedurl = $feeddata->view->uri;
+ $feedname = $feeddata->view->displayName;
+ } else {
+ $feedurl = $feed;
+ $feedname = $feed;
+ }
+
foreach (array_reverse($data->feed) as $entry) {
if (!Relay::isWantedLanguage($entry->post->record->text)) {
Logger::debug('Unwanted language detected', ['text' => $entry->post->record->text]);
continue;
}
- bluesky_process_post($entry->post, $uid, Item::PR_TAG, 0);
+ $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($entry->reason)) {
bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid);
}
{
$uri = bluesky_get_uri($post);
- if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) {
- return 0;
+ if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid]) || $id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) {
+ return $id;
}
Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']);
'author-link' => $contact['url'],
'author-avatar' => $contact['avatar'],
'plink' => $contact['alias'] . '/post/' . $parts->rkey,
+ 'source' => json_encode($post),
];
$item['uri-id'] = ItemURI::getIdByURI($uri);
}
if (!empty($embed->media)) {
- bluesky_add_media($embed->media, $item, $fetch_uid, $level);
+ $item = bluesky_add_media($embed->media, $item, $fetch_uid, $level);
}
break;
$id = tumblr_process_post($post, $uid, Item::PR_TAG);
if (!empty($id)) {
Logger::debug('Tag post imported', ['tag' => $tag, 'id' => $id]);
+ $post = Post::selectFirst(['uri-id'], ['id' => $id]);
+ $stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $tag);
+ Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]);
}
}
}