diff --git a/src/Command/CacheMediaDiscoveryCommand.php b/src/Command/CacheMediaDiscoveryCommand.php index b447706..645d9cb 100644 --- a/src/Command/CacheMediaDiscoveryCommand.php +++ b/src/Command/CacheMediaDiscoveryCommand.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Contracts\Cache\CacheInterface; #[AsCommand( @@ -35,6 +36,7 @@ class CacheMediaDiscoveryCommand extends Command private readonly NostrClient $nostrClient, private readonly CacheInterface $cache, private readonly LoggerInterface $logger, + private readonly ParameterBagInterface $params, ) { parent::__construct(); } @@ -61,7 +63,8 @@ class CacheMediaDiscoveryCommand extends Command $allHashtags = array_merge($allHashtags, self::TOPIC_HASHTAGS[$topic]); } - $cacheKey = 'media_discovery_events_all'; + $env = $this->params->get('kernel.environment'); + $cacheKey = 'media_discovery_events_all_' . $env; if ($force) { $io->info('Force refresh enabled - deleting existing cache'); diff --git a/src/Controller/MediaDiscoveryController.php b/src/Controller/MediaDiscoveryController.php index 13ef1bf..9b6b89f 100644 --- a/src/Controller/MediaDiscoveryController.php +++ b/src/Controller/MediaDiscoveryController.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Contracts\Cache\CacheInterface; @@ -22,7 +23,7 @@ class MediaDiscoveryController extends AbstractController ]; #[Route('/multimedia', name: 'media-discovery')] - public function discover(CacheInterface $cache): Response + public function discover(CacheInterface $cache, ParameterBagInterface $params): Response { // Defaulting to all, might do topics later try { @@ -33,7 +34,8 @@ class MediaDiscoveryController extends AbstractController } // Cache key for all media events - $cacheKey = 'media_discovery_events_all'; + $env = $params->get('kernel.environment'); + $cacheKey = 'media_discovery_events_all_' . $env; // Read from cache only - the cache is populated by the CacheMediaDiscoveryCommand $allCachedEvents = $cache->get($cacheKey, function () { diff --git a/src/Service/NostrClient.php b/src/Service/NostrClient.php index ee0e0c3..81423ee 100644 --- a/src/Service/NostrClient.php +++ b/src/Service/NostrClient.php @@ -826,23 +826,6 @@ class NostrClient { $allEvents = []; - // Prefer local relay if configured - if ($this->nostrDefaultRelay) { - $this->logger->info('Using local relay for media discovery hashtag fetch', [ - 'relay' => $this->nostrDefaultRelay, - 'hashtags' => $hashtags, - ]); - $relayset = $this->createRelaySet([$this->nostrDefaultRelay]); - } else { - // Fallback to known public media-friendly relays - $relayUrls = ['wss://theforest.nostr1.com', 'wss://relay.nostr.band']; - $this->logger->info('Using public relays for media discovery hashtag fetch', [ - 'relays' => $relayUrls, - 'hashtags' => $hashtags, - ]); - $relayset = $this->createRelaySet($relayUrls); - } - // Fetch events for each hashtag foreach ($hashtags as $hashtag) { $request = $this->createNostrRequest( @@ -851,7 +834,7 @@ class NostrClient 'tag' => ['#t', [$hashtag]], 'limit' => 100 // Fetch up to 100 per hashtag ], - relaySet: $relayset + relaySet: $this->createRelaySet(static::REPUTABLE_RELAYS) ); $events = $this->processResponse($request->send(), function($event) {