From 5402680abfc537b43ca086f63a17e60e87f65a1f Mon Sep 17 00:00:00 2001 From: Brock H Caldwell Date: Wed, 23 Apr 2025 15:38:39 -0500 Subject: [PATCH] fix: creates separate Symfony Message Handler for download --- config/packages/messenger.yaml | 18 ++++- .../Action/Handler/DownloadMediaHandler.php | 7 -- .../DownloadMediaMessageHandler.php | 20 ++++++ templates/torrentio/movies.html.twig | 66 +----------------- .../torrentio/partial/option-table.html.twig | 67 ++++++++++++++++++ templates/torrentio/tvshows.html.twig | 68 +------------------ 6 files changed, 104 insertions(+), 142 deletions(-) create mode 100644 src/Download/Framework/MessageHandler/DownloadMediaMessageHandler.php create mode 100644 templates/torrentio/partial/option-table.html.twig diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index 672b6c4..3ef0967 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -5,13 +5,25 @@ framework: transports: # https://symfony.com/doc/current/messenger.html#transport-configuration - # async: '%env(MESSENGER_TRANSPORT_DSN)%' - # failed: 'doctrine://default?queue_name=failed' - # sync: 'sync://' + async: + dsn: '%env(MESSENGER_TRANSPORT_DSN)%' + options: + use_notify: true + check_delayed_interval: 60000 + retry_strategy: + max_retries: 1 + multiplier: 1 + failed: 'doctrine://default?queue_name=failed' + + default_bus: messenger.bus.default + + buses: + messenger.bus.default: [] routing: # Route your messages to the transports # 'App\Message\YourMessage': async + 'App\Download\Action\Command\DownloadMediaCommand': async # when@test: # framework: diff --git a/src/Download/Action/Handler/DownloadMediaHandler.php b/src/Download/Action/Handler/DownloadMediaHandler.php index b7a8d70..cfaada3 100644 --- a/src/Download/Action/Handler/DownloadMediaHandler.php +++ b/src/Download/Action/Handler/DownloadMediaHandler.php @@ -9,11 +9,9 @@ use App\Download\Downloader\DownloaderInterface; use OneToMany\RichBundle\Contract\CommandInterface; use OneToMany\RichBundle\Contract\HandlerInterface; use OneToMany\RichBundle\Contract\ResultInterface; -use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException; /** @implements HandlerInterface */ -#[AsMessageHandler] readonly class DownloadMediaHandler implements HandlerInterface { public function __construct( @@ -21,11 +19,6 @@ readonly class DownloadMediaHandler implements HandlerInterface private DownloadRepository $downloadRepository, ) {} - public function __invoke(CommandInterface $command) - { - $this->handle($command); - } - public function handle(CommandInterface $command): ResultInterface { $download = $this->downloadRepository->insert( diff --git a/src/Download/Framework/MessageHandler/DownloadMediaMessageHandler.php b/src/Download/Framework/MessageHandler/DownloadMediaMessageHandler.php new file mode 100644 index 0000000..1be4208 --- /dev/null +++ b/src/Download/Framework/MessageHandler/DownloadMediaMessageHandler.php @@ -0,0 +1,20 @@ +downloadMediaHandler->handle($command); + } +} \ No newline at end of file diff --git a/templates/torrentio/movies.html.twig b/templates/torrentio/movies.html.twig index 293e962..26203f0 100644 --- a/templates/torrentio/movies.html.twig +++ b/templates/torrentio/movies.html.twig @@ -1,69 +1,5 @@
- - - - - - - - - - - - - - {% for result in results.results %} - - - - - - - - - - {% endfor %} - -
- Size - - Resolution - - Codec - - Seeders - - Provider - - Language - -
- {{ result.size }} - - {{ result.resolution }} - - {{ result.codec }} - - {{ result.seeders }} - - {{ result.provider }} - - {{ result.languageFlags }} - - - Download - - -
+ {{ include('torrentio/partial/option-table.html.twig', {controller: 'movie-results'}) }}
\ No newline at end of file diff --git a/templates/torrentio/partial/option-table.html.twig b/templates/torrentio/partial/option-table.html.twig new file mode 100644 index 0000000..a420835 --- /dev/null +++ b/templates/torrentio/partial/option-table.html.twig @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + {% for result in results.results %} + + + + + + + + + + {% endfor %} + + \ No newline at end of file diff --git a/templates/torrentio/tvshows.html.twig b/templates/torrentio/tvshows.html.twig index 92a539e..b893ae7 100644 --- a/templates/torrentio/tvshows.html.twig +++ b/templates/torrentio/tvshows.html.twig @@ -18,72 +18,6 @@
- - - - - - - - - - - - - - {% for result in results.results %} - - - - - - - - - - {% endfor %} - - + {{ include('torrentio/partial/option-table.html.twig', {controller: 'tv-results'}) }}