fix: creates separate Symfony Message Handler for download
This commit is contained in:
@@ -5,13 +5,25 @@ framework:
|
|||||||
|
|
||||||
transports:
|
transports:
|
||||||
# https://symfony.com/doc/current/messenger.html#transport-configuration
|
# https://symfony.com/doc/current/messenger.html#transport-configuration
|
||||||
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
|
async:
|
||||||
# failed: 'doctrine://default?queue_name=failed'
|
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
|
||||||
# sync: 'sync://'
|
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:
|
routing:
|
||||||
# Route your messages to the transports
|
# Route your messages to the transports
|
||||||
# 'App\Message\YourMessage': async
|
# 'App\Message\YourMessage': async
|
||||||
|
'App\Download\Action\Command\DownloadMediaCommand': async
|
||||||
|
|
||||||
# when@test:
|
# when@test:
|
||||||
# framework:
|
# framework:
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ use App\Download\Downloader\DownloaderInterface;
|
|||||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
use OneToMany\RichBundle\Contract\HandlerInterface;
|
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
|
||||||
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
|
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
|
||||||
|
|
||||||
/** @implements HandlerInterface<DownloadMediaCommand, DownloadMediaResult> */
|
/** @implements HandlerInterface<DownloadMediaCommand, DownloadMediaResult> */
|
||||||
#[AsMessageHandler]
|
|
||||||
readonly class DownloadMediaHandler implements HandlerInterface
|
readonly class DownloadMediaHandler implements HandlerInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@@ -21,11 +19,6 @@ readonly class DownloadMediaHandler implements HandlerInterface
|
|||||||
private DownloadRepository $downloadRepository,
|
private DownloadRepository $downloadRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function __invoke(CommandInterface $command)
|
|
||||||
{
|
|
||||||
$this->handle($command);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(CommandInterface $command): ResultInterface
|
public function handle(CommandInterface $command): ResultInterface
|
||||||
{
|
{
|
||||||
$download = $this->downloadRepository->insert(
|
$download = $this->downloadRepository->insert(
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Framework\MessageHandler;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\DownloadMediaCommand;
|
||||||
|
use App\Download\Action\Handler\DownloadMediaHandler;
|
||||||
|
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||||
|
|
||||||
|
#[AsMessageHandler(handles: DownloadMediaCommand::class)]
|
||||||
|
class DownloadMediaMessageHandler
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private DownloadMediaHandler $downloadMediaHandler,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function __invoke(DownloadMediaCommand $command)
|
||||||
|
{
|
||||||
|
$this->downloadMediaHandler->handle($command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,69 +1,5 @@
|
|||||||
<div class="p-4 flex flex-col gap-6 bg-orange-500 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60 rounded-md">
|
<div class="p-4 flex flex-col gap-6 bg-orange-500 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60 rounded-md">
|
||||||
<div class="overflow-hidden rounded-md">
|
<div class="overflow-hidden rounded-md">
|
||||||
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400" {{ stimulus_target('movie_results', 'list') }} >
|
{{ include('torrentio/partial/option-table.html.twig', {controller: 'movie-results'}) }}
|
||||||
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
|
||||||
<tr class="dark:bg-stone-600 overflow-hidden">
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Size
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Resolution
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Codec
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Seeders
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Provider
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Language
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for result in results.results %}
|
|
||||||
<tr class="bg-white border-b dark:bg-slate-700 dark:border-gray-600 border-gray-200" data-languages="{{ result.languages|json_encode }}" data-provider="{{ result.provider }}">
|
|
||||||
<td id="size" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.size }}
|
|
||||||
</td>
|
|
||||||
<td id="resolution" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.resolution }}
|
|
||||||
</td>
|
|
||||||
<td id="codec" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.codec }}
|
|
||||||
</td>
|
|
||||||
<td id="seeders" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.seeders }}
|
|
||||||
</td>
|
|
||||||
<td id="provider" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50" data-provider="{{ result.provider }}">
|
|
||||||
{{ result.provider }}
|
|
||||||
</td>
|
|
||||||
<td id="language" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50" data-languages="{{ result.languages|json_encode }}">
|
|
||||||
{{ result.languageFlags }}
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50 flex flex-row gap-2 items-center justify-end">
|
|
||||||
<span class="p-1.5 bg-green-600 rounded-md text-gray-50">
|
|
||||||
Download
|
|
||||||
</span>
|
|
||||||
<label for="select">
|
|
||||||
<input id="select" type="checkbox" name="select" />
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
67
templates/torrentio/partial/option-table.html.twig
Normal file
67
templates/torrentio/partial/option-table.html.twig
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 hidden"
|
||||||
|
{{ stimulus_target(controller, "list") }}
|
||||||
|
>
|
||||||
|
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
||||||
|
<tr class="dark:bg-stone-600 overflow-hidden">
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
Size
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
Resolution
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
Codec
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
Seeders
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
Provider
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
Language
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for result in results.results %}
|
||||||
|
<tr class="bg-white border-b dark:bg-slate-700 dark:border-gray-600 border-gray-200" data-languages="{{ result.languages|json_encode }}" data-season="{{ results.season }}">
|
||||||
|
<td id="size" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
||||||
|
{{ result.size }}
|
||||||
|
</td>
|
||||||
|
<td id="resolution" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
||||||
|
{{ result.resolution }}
|
||||||
|
</td>
|
||||||
|
<td id="codec" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
||||||
|
{{ result.codec }}
|
||||||
|
</td>
|
||||||
|
<td id="seeders" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
||||||
|
{{ result.seeders }}
|
||||||
|
</td>
|
||||||
|
<td id="provider" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50" data-provider="{{ result.provider }}">
|
||||||
|
{{ result.provider }}
|
||||||
|
</td>
|
||||||
|
<td id="language" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50" data-languages="{{ result.languages|json_encode }}">
|
||||||
|
{{ result.languageFlags|raw }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50 flex flex-row gap-2 items-center justify-end">
|
||||||
|
<button class="p-1.5 bg-green-600 rounded-md text-gray-50">
|
||||||
|
Download
|
||||||
|
</button>
|
||||||
|
<label for="select">
|
||||||
|
<input id="select" type="checkbox" name="select" />
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -18,72 +18,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline-block overflow-hidden rounded-lg">
|
<div class="inline-block overflow-hidden rounded-lg">
|
||||||
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 hidden"
|
{{ include('torrentio/partial/option-table.html.twig', {controller: 'tv-results'}) }}
|
||||||
data-tv-results-target="list"
|
|
||||||
>
|
|
||||||
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
|
||||||
<tr class="dark:bg-stone-600 overflow-hidden">
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Size
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Resolution
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Codec
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Seeders
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Provider
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
Language
|
|
||||||
</th>
|
|
||||||
<th scope="col"
|
|
||||||
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for result in results.results %}
|
|
||||||
<tr class="bg-white border-b dark:bg-slate-700 dark:border-gray-600 border-gray-200" data-languages="{{ result.languages|json_encode }}" data-season="{{ results.season }}">
|
|
||||||
<td id="size" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.size }}
|
|
||||||
</td>
|
|
||||||
<td id="resolution" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.resolution }}
|
|
||||||
</td>
|
|
||||||
<td id="codec" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.codec }}
|
|
||||||
</td>
|
|
||||||
<td id="seeders" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
|
|
||||||
{{ result.seeders }}
|
|
||||||
</td>
|
|
||||||
<td id="provider" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50" data-provider="{{ result.provider }}">
|
|
||||||
{{ result.provider }}
|
|
||||||
</td>
|
|
||||||
<td id="language" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50" data-languages="{{ result.languages|json_encode }}">
|
|
||||||
{{ result.languageFlags|raw }}
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50 flex flex-row gap-2 items-center justify-end">
|
|
||||||
<span class="p-1.5 bg-green-600 rounded-md text-gray-50">
|
|
||||||
Download
|
|
||||||
</span>
|
|
||||||
<label for="select">
|
|
||||||
<input id="select" type="checkbox" name="select" />
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user