Build Reactive Signals for Bluesky's AT Protocol Firehose in Laravel
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix CID normalization to use AT Protocol link format

+18 -1
+18 -1
src/Services/FirehoseConsumer.php
··· 224 224 // Decode the CBOR block to get the record data 225 225 $decoded = rescue(fn () => CBOR::decode($blocks[$cidStr])); 226 226 if (is_array($decoded)) { 227 - $record = $decoded; 227 + $record = $this->normalizeCids($decoded); 228 228 } 229 229 } 230 230 ··· 267 267 kind: 'commit', 268 268 commit: $commitEvent 269 269 ); 270 + } 271 + 272 + /** 273 + * Normalize CID objects to AT Protocol link format. 274 + */ 275 + protected function normalizeCids(array $data): array 276 + { 277 + foreach ($data as $key => $value) { 278 + if ($value instanceof CID) { 279 + // Convert CID to AT Protocol link format 280 + $data[$key] = ['$link' => $value->toString()]; 281 + } elseif (is_array($value)) { 282 + $data[$key] = $this->normalizeCids($value); 283 + } 284 + } 285 + 286 + return $data; 270 287 } 271 288 272 289 /**