MagnetRedirectController added (for working magnet-links in the Telegram bot).

This commit is contained in:
Alexey Skobkin 2019-01-29 20:32:16 +03:00
parent 47a671c493
commit 03a10aa231
2 changed files with 23 additions and 0 deletions

View file

@ -16,6 +16,15 @@ torrents_show:
method: GET
id: '\d+'
# Mainly for Telegram bot
magnet_redirect:
path: /magnet/{infoHash}
controller: App\Controller\MagnetRedirectController::redirect
requirements:
method: GET
# SHA-1 hash
infoHash: '[0-9a-fA-F]{40}'
user_register:
path: /register/{inviteCode}
controller: App\Controller\UserController::register

View file

@ -0,0 +1,14 @@
<?php
namespace App\Controller;
use App\Magnet\MagnetGenerator;
use Symfony\Component\HttpFoundation\RedirectResponse;
class MagnetRedirectController
{
public function redirect(string $infoHash, MagnetGenerator $magnetGenerator): RedirectResponse
{
return new RedirectResponse($magnetGenerator->generate($infoHash), RedirectResponse::HTTP_TEMPORARY_REDIRECT);
}
}