···
244
-
/*return array_map(function($item) {
245
-
return $item->json();
249
-
/*$body->feed = array_map(function ($feed) {
250
-
preg_match('/at:\/\/(did:plc:[a-z0-9]+)\/app.bsky.feed.post\/([a-z0-9]+)/', $feed->post, $uriComponents);
251
-
$did = $uriComponents[1];
252
-
$rkey = $uriComponents[2];
253
-
return $this->getPost($did, $rkey, true);
···
function getReplyRecords(string $post):array {
433
-
/*$ret = $this->getConstellationLinkData($post, "app.bsky.feed.post", ".reply.root.uri");
423
+
$ret = $this->getConstellationLinkData($post, "app.bsky.feed.post", ".reply.root.uri");
435
-
return array_map(function ($rec) {
436
-
$slingshotRecord = $this->getSlingshotData($rec->did, $rec->collection, $rec->rkey, ['reverse' => true]);
437
-
return $this->sanitizePost($slingshotRecord, true);
438
-
}, $ret->linking_records);
425
+
return await(all(array_map(function ($rec) {
426
+
return async(fn() => $this->sanitizePost($this->getSlingshotData($rec->did, $rec->collection, $rec->rkey, ['reverse' => true]), true));
427
+
}, $ret->linking_records)));
···
if (!$postData) return false;
452
-
$postData = array_map(function($p) {
441
+
$postData = await(all(array_map(function($p) {
$uriComponents = $this->splitAtUri($p->uri);
$cache = \requestPostCache($uriComponents->rkey);
if ($cache) return $this->sanitizeCachedPost($cache);
456
-
$post = $this->getPost($uriComponents->did, $uriComponents->rkey, true);
458
-
}, $postData->records);
445
+
return async(fn() => $this->getPost($uriComponents->did, $uriComponents->rkey, true));
446
+
}, $postData->records)));
···
$rkey = $uriComponents[2];
$authorInfo = $this->getUserInfo($did, 'did');
$facets = property_exists($post->value, 'facets') ? $this->sanitizeFacets($post->value->facets) : [];
545
+
$waitingFor = await(all([
546
+
'authorInfo' => async(fn() => $this->getUserInfo($did, 'did')),
547
+
'replyCount' => async(fn() => $this->getReplies($post->uri)),
548
+
'repostCount' => async(fn() => $this->getReposts($post->uri)),
549
+
'likeCount' => async(fn() => $this->getLikes($post->uri)),
550
+
'quoteCount' => async(fn() => $this->getQuotes($post->uri))
559
-
'displayName' => $authorInfo->displayName,
560
-
'handle' => $authorInfo->handle,
561
-
'avatar' => $authorInfo->avatar,
554
+
'displayName' => $waitingFor['authorInfo']->displayName,
555
+
'handle' => $waitingFor['authorInfo']->handle,
556
+
'avatar' => $waitingFor['authorInfo']->avatar,
563
-
'profileLink' => '/u/'.$authorInfo->handle,
558
+
'profileLink' => '/u/'.$waitingFor['authorInfo']->handle,
'pds' => $authorInfo->pds,
'postLink' => '/u/'.$authorInfo->handle.'/'.$rkey,
'content' => property_exists($post->value, 'text') ? $this->applyFacets($post->value->text, $facets) : '',
570
-
'replyCount' => $this->getReplies($post->uri),
571
-
'repostCount' => $this->getReposts($post->uri),
572
-
'likeCount' => $this->getLikes($post->uri),
573
-
'quoteCount' => $this->getQuotes($post->uri),
565
+
'replyCount' => $waitingFor['replyCount'],
566
+
'repostCount' => $waitingFor['repostCount'],
567
+
'likeCount' => $waitingFor['likeCount'],
568
+
'quoteCount' => $waitingFor['quoteCount'],
'createdAt' => $post->value->createdAt,
'embedType' => property_exists($post->value, 'embed') ? $post->value->embed->{'$type'} : null,
'embeds' => property_exists($post->value, 'embed') ? $this->sanitizeEmbeds($post->value->embed, $authorInfo) : [],