diff --git a/src/Controller/AuthorController.php b/src/Controller/AuthorController.php index c5b49ed..7c1b597 100644 --- a/src/Controller/AuthorController.php +++ b/src/Controller/AuthorController.php @@ -29,7 +29,7 @@ class AuthorController extends AbstractController $author = $redisCacheService->getMetadata($keyUtil->npubToHex($npub)); // Use paginated cached media events - fetches 200 from relays, serves first 24 - $paginatedData = $redisCacheService->getMediaEventsPaginated($npub, 1, 24); + $paginatedData = $redisCacheService->getMediaEventsPaginated($keyUtil->npubToHex($npub), 1, 24); $mediaEvents = $paginatedData['events']; // Encode event IDs as note1... for each event diff --git a/src/Service/NostrClient.php b/src/Service/NostrClient.php index 515560d..615683a 100644 --- a/src/Service/NostrClient.php +++ b/src/Service/NostrClient.php @@ -34,7 +34,7 @@ class NostrClient 'wss://relay.primal.net', 'wss://nos.lol', 'wss://relay.snort.social', - 'wss://nostr.land', + // 'wss://nostr.land', // requires auth that doesn't currently work! 'wss://purplepag.es', ]; @@ -46,7 +46,8 @@ class NostrClient { $this->defaultRelaySet = new RelaySet(); $this->defaultRelaySet->addRelay(new Relay('wss://theforest.nostr1.com')); // public aggregator relay - $this->defaultRelaySet->addRelay(new Relay('wss://nostr.land')); // public aggregator relay + $this->defaultRelaySet->addRelay(new Relay('wss://relay.damus.io')); // public aggregator relay + $this->defaultRelaySet->addRelay(new Relay('wss://relay.primal.net')); // public aggregator relay } /** diff --git a/src/Service/RedisCacheService.php b/src/Service/RedisCacheService.php index 6717051..17efd07 100644 --- a/src/Service/RedisCacheService.php +++ b/src/Service/RedisCacheService.php @@ -328,25 +328,25 @@ readonly class RedisCacheService /** * Get all media events for pagination (fetches large batch, caches, returns paginated) * - * @param string $npub The author's npub + * @param string $pubkey The author's pubkey * @param int $page Page number (1-based) * @param int $pageSize Number of items per page * @return array ['events' => array, 'hasMore' => bool, 'total' => int] */ - public function getMediaEventsPaginated(string $npub, int $page = 1, int $pageSize = 60): array + public function getMediaEventsPaginated(string $pubkey, int $page = 1, int $pageSize = 60): array { // Cache key for all media events (not page-specific) - $cacheKey = 'media_all_' . $npub; + $cacheKey = 'media_all_' . $pubkey; try { // Fetch and cache all media events - $allMediaEvents = $this->redisCache->get($cacheKey, function (ItemInterface $item) use ($npub) { + $allMediaEvents = $this->redisCache->get($cacheKey, function (ItemInterface $item) use ($pubkey) { $item->expiresAfter(600); // 10 minutes cache try { // Fetch a large batch to account for deduplication // Nostr relays are unstable, so we fetch more than we need - $mediaEvents = $this->nostrClient->getAllMediaEventsForPubkey($npub, 200); + $mediaEvents = $this->nostrClient->getAllMediaEventsForPubkey($pubkey, 200); // Deduplicate by event ID $uniqueEvents = []; @@ -364,7 +364,7 @@ readonly class RedisCacheService return $mediaEvents; } catch (\Exception $e) { - $this->logger->error('Error getting media events.', ['exception' => $e, 'npub' => $npub]); + $this->logger->error('Error getting media events.', ['exception' => $e, 'pubkey' => $pubkey]); return []; } });