$causer = bluesky_get_contact($entry->post->author, 0, $uid);
if (!empty($entry->reply)) {
if (!empty($entry->reply->root)) {
- bluesky_complete_post($entry->reply->root, $uid, Item::PR_COMMENT, $causer['id'], $last_poll);
+ bluesky_complete_post($entry->reply->root, $uid, Item::PR_COMMENT, $causer['id'], $last_poll, Conversation::PARCEL_CONNECTOR);
}
if (!empty($entry->reply->parent)) {
- bluesky_complete_post($entry->reply->parent, $uid, Item::PR_COMMENT, $causer['id'], $last_poll);
+ bluesky_complete_post($entry->reply->parent, $uid, Item::PR_COMMENT, $causer['id'], $last_poll, Conversation::PARCEL_CONNECTOR);
}
}
- bluesky_process_post($entry->post, $uid, $uid, Item::PR_NONE, 0, 0, $last_poll);
+ bluesky_process_post($entry->post, $uid, $uid, Item::PR_NONE, 0, 0, $last_poll, Conversation::PARCEL_CONNECTOR);
if (!empty($entry->reason)) {
bluesky_process_reason($entry->reason, bluesky_get_uri($entry->post), $uid);
}
}
}
-function bluesky_complete_post(stdClass $post, int $uid, int $post_reason, int $causer, int $last_poll): int
+function bluesky_complete_post(stdClass $post, int $uid, int $post_reason, int $causer, int $last_poll, int $protocol): int
{
$complete = DI::pConfig()->get($uid, 'bluesky', 'complete_threads');
$existing_uri = bluesky_fetch_post(bluesky_get_uri($post), $uid);
$uri = bluesky_fetch_missing_post(bluesky_get_uri($post), $uid, $uid, $post_reason, $causer, 0, $last_poll, '', true);
$uri_id = bluesky_fetch_uri_id($uri, $uid);
} else {
- $uri_id = bluesky_process_post($post, $uid, $uid, $post_reason, $causer, 0, $last_poll);
+ $uri_id = bluesky_process_post($post, $uid, $uid, $post_reason, $causer, 0, $last_poll, $protocol);
}
return $uri_id;
}
Logger::debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
switch ($notification->reason) {
case 'like':
- $item = bluesky_get_header($notification, $uri, $uid, $uid, $last_poll);
+ $item = bluesky_get_header($notification, $uri, $uid, $uid, $last_poll, Conversation::PARCEL_CONNECTOR);
$item['gravity'] = Item::GRAVITY_ACTIVITY;
$item['body'] = $item['verb'] = Activity::LIKE;
$item['thr-parent'] = bluesky_get_uri($notification->record->subject);
break;
case 'repost':
- $item = bluesky_get_header($notification, $uri, $uid, $uid, $last_poll);
+ $item = bluesky_get_header($notification, $uri, $uid, $uid, $last_poll, Conversation::PARCEL_CONNECTOR);
$item['gravity'] = Item::GRAVITY_ACTIVITY;
$item['body'] = $item['verb'] = Activity::ANNOUNCE;
$item['thr-parent'] = bluesky_get_uri($notification->record->subject);
continue;
}
$causer = bluesky_get_contact($entry->post->author, 0, $uid);
- $uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], $last_poll);
+ $uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], $last_poll, Conversation::PARCEL_CONNECTOR);
if (!empty($uri_id)) {
$stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
}
}
-function bluesky_process_post(stdClass $post, int $uid, int $fetch_uid, int $post_reason, int $causer, 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 $protocol): int
{
$uri = bluesky_get_uri($post);
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, $fetch_uid, $last_poll);
+ $item = bluesky_get_header($post, $uri, $uid, $fetch_uid, $last_poll, $protocol);
$item = bluesky_get_content($item, $post->record, $uri, $uid, $fetch_uid, $level, $last_poll);
if (empty($item)) {
return 0;
return bluesky_fetch_uri_id($uri, $uid);
}
-function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_uid, int $last_poll = 0): array
+function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_uid, int $last_poll, int $protocol): array
{
$parts = bluesky_get_uri_parts($uri);
if (empty($post->author) || empty($post->cid) || empty($parts->rkey)) {
$contact = bluesky_get_contact($post->author, $uid, $fetch_uid);
$item = [
'network' => Protocol::BLUESKY,
- 'protocol' => Conversation::PARCEL_CONNECTOR,
+ 'protocol' => $protocol,
'uid' => $uid,
'wall' => false,
'uri' => $uri,
return $class;
}
-function bluesky_fetch_missing_post(string $uri, int $uid, int $fetch_uid, int $post_reason, int $causer, int $level, int $last_poll, string $fallback = '', bool $always_fetch = false): 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 = '', bool $always_fetch = false, int $Protocol = Conversation::PARCEL_CONNECTOR): string
{
$fetched_uri = bluesky_fetch_post($uri, $uid);
if (!$always_fetch && !empty($fetched_uri)) {
$parents = bluesky_fetch_parents($data->thread->parent, $uid);
foreach ($parents as $parent) {
- $uri_id = bluesky_process_post($parent, $uid, $fetch_uid, Item::PR_FETCHED, $causer, $level, $last_poll);
+ $uri_id = bluesky_process_post($parent, $uid, $fetch_uid, Item::PR_FETCHED, $causer, $level, $last_poll, $Protocol);
Logger::debug('Parent created', ['uri-id' => $uri_id]);
}
}
- return bluesky_process_thread($data->thread, $uid, $fetch_uid, $post_reason, $causer, $level, $last_poll);
+ return bluesky_process_thread($data->thread, $uid, $fetch_uid, $post_reason, $causer, $level, $last_poll, $Protocol);
}
function bluesky_fetch_parents(stdClass $parent, int $uid, array $parents = []): array
return 0;
}
-function bluesky_process_thread(stdClass $thread, int $uid, int $fetch_uid, int $post_reason, int $causer, int $level, int $last_poll): string
+function bluesky_process_thread(stdClass $thread, int $uid, int $fetch_uid, int $post_reason, int $causer, int $level, int $last_poll, int $protocol): string
{
if (empty($thread->post)) {
Logger::info('Invalid post', ['post' => $thread]);
$fetched_uri = bluesky_fetch_post($uri, $uid);
if (empty($fetched_uri)) {
- $uri_id = bluesky_process_post($thread->post, $uid, $fetch_uid, $post_reason, $causer, $level, $last_poll);
+ $uri_id = bluesky_process_post($thread->post, $uid, $fetch_uid, $post_reason, $causer, $level, $last_poll, $protocol);
if ($uri_id) {
Logger::debug('Post has been processed and stored', ['uri-id' => $uri_id, 'uri' => $uri]);
return $uri;
}
foreach ($thread->replies ?? [] as $reply) {
- $reply_uri = bluesky_process_thread($reply, $uid, $fetch_uid, Item::PR_FETCHED, $causer, $level, $last_poll);
+ $reply_uri = bluesky_process_thread($reply, $uid, $fetch_uid, Item::PR_FETCHED, $causer, $level, $last_poll, $protocol);
Logger::debug('Reply has been processed', ['uri' => $uri, 'reply' => $reply_uri]);
}
$cid = Contact::insert($public_fields);
} else {
$cid = $contact['id'];
+ Logger::debug('Update contact', ['fields' => $public_fields, 'id' => $cid]);
Contact::update($public_fields, ['id' => $cid], true);
}
$cid = Contact::insert($fields);
} else {
$cid = $contact['id'];
+ Logger::debug('Update contact', ['fields' => $fields, 'id' => $cid]);
Contact::update($fields, ['id' => $cid], true);
}
Logger::debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]);
];
if (!$update) {
- Logger::debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]);
+ Logger::debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url'], 'fields' => $fields]);
return $fields;
}