Expand StationFeatures.
This commit is contained in:
parent
6e9af6f1f4
commit
2f19f94005
|
@ -100,7 +100,7 @@ return function (App\Event\BuildStationMenu $e) {
|
|||
'label' => __('SFTP Users'),
|
||||
'class' => 'text-muted',
|
||||
'url' => (string)$router->fromHere('stations:sftp_users:index'),
|
||||
'visible' => App\Service\SftpGo::isSupportedForStation($station),
|
||||
'visible' => StationFeatures::Sftp->supportedForStation($station),
|
||||
'permission' => StationPermissions::Media,
|
||||
],
|
||||
'bulk_media' => [
|
||||
|
|
|
@ -20,8 +20,7 @@ return static function (RouteCollectorProxy $group) {
|
|||
['GET', 'POST'],
|
||||
'/nowplaying/update',
|
||||
Controller\Api\Stations\UpdateMetadataAction::class
|
||||
)
|
||||
->add(new Middleware\Permissions(StationPermissions::Broadcasting, true));
|
||||
)->add(new Middleware\Permissions(StationPermissions::Broadcasting, true));
|
||||
|
||||
$group->get('/profile', Controller\Api\Stations\ProfileAction::class)
|
||||
->setName('api:stations:profile')
|
||||
|
@ -38,17 +37,12 @@ return static function (RouteCollectorProxy $group) {
|
|||
Controller\Api\Stations\ProfileEditController::class . ':putProfileAction'
|
||||
)->add(new Middleware\Permissions(StationPermissions::Profile, true));
|
||||
|
||||
$group->get('/quota[/{type}]', Controller\Api\Stations\GetQuotaAction::class)
|
||||
->setName('api:stations:quota')
|
||||
->add(new Middleware\Permissions(StationPermissions::View, true));
|
||||
|
||||
$group->get('/schedule', Controller\Api\Stations\ScheduleAction::class)
|
||||
->setName('api:stations:schedule');
|
||||
|
||||
$group->get('/history', Controller\Api\Stations\HistoryController::class)
|
||||
->setName('api:stations:history')
|
||||
->add(new Middleware\Permissions(StationPermissions::Reports, true));
|
||||
|
||||
/*
|
||||
* Upcoming Song Queue
|
||||
*/
|
||||
$group->group(
|
||||
'/queue',
|
||||
function (RouteCollectorProxy $group) {
|
||||
|
@ -63,7 +57,11 @@ return static function (RouteCollectorProxy $group) {
|
|||
}
|
||||
)->add(new Middleware\Permissions(StationPermissions::Broadcasting, true));
|
||||
|
||||
/*
|
||||
* Song Requests
|
||||
*/
|
||||
$group->get('/requests', Controller\Api\Stations\RequestsController::class . ':listAction')
|
||||
->add(new Middleware\StationSupportsFeature(StationFeatures::Requests))
|
||||
->setName('api:requests:list');
|
||||
|
||||
$group->map(
|
||||
|
@ -72,8 +70,12 @@ return static function (RouteCollectorProxy $group) {
|
|||
Controller\Api\Stations\RequestsController::class . ':submitAction'
|
||||
)
|
||||
->setName('api:requests:submit')
|
||||
->add(new Middleware\StationSupportsFeature(StationFeatures::Requests))
|
||||
->add(new Middleware\RateLimit('api', 5, 2));
|
||||
|
||||
/*
|
||||
* On-Demand Streaming
|
||||
*/
|
||||
$group->get('/ondemand', Controller\Api\Stations\OnDemand\ListAction::class)
|
||||
->setName('api:stations:ondemand:list');
|
||||
|
||||
|
@ -81,27 +83,6 @@ return static function (RouteCollectorProxy $group) {
|
|||
->setName('api:stations:ondemand:download')
|
||||
->add(new Middleware\RateLimit('ondemand', 1, 2));
|
||||
|
||||
$group->get('/listeners', Controller\Api\Stations\ListenersAction::class)
|
||||
->setName('api:listeners:index')
|
||||
->add(new Middleware\Permissions(StationPermissions::Reports, true));
|
||||
|
||||
$group->get(
|
||||
'/waveform/{media_id:[a-zA-Z0-9\-]+}.json',
|
||||
Controller\Api\Stations\Waveform\GetWaveformAction::class
|
||||
)->setName('api:stations:media:waveform');
|
||||
|
||||
$group->get('/art/{media_id:[a-zA-Z0-9\-]+}.jpg', Controller\Api\Stations\Art\GetArtAction::class)
|
||||
->setName('api:stations:media:art');
|
||||
|
||||
$group->get('/art/{media_id:[a-zA-Z0-9\-]+}', Controller\Api\Stations\Art\GetArtAction::class)
|
||||
->setName('api:stations:media:art-internal');
|
||||
|
||||
$group->post('/art/{media_id:[a-zA-Z0-9]+}', Controller\Api\Stations\Art\PostArtAction::class)
|
||||
->add(new Middleware\Permissions(StationPermissions::Media, true));
|
||||
|
||||
$group->delete('/art/{media_id:[a-zA-Z0-9]+}', Controller\Api\Stations\Art\DeleteArtAction::class)
|
||||
->add(new Middleware\Permissions(StationPermissions::Media, true));
|
||||
|
||||
/*
|
||||
* Podcast Public Pages
|
||||
*/
|
||||
|
@ -231,6 +212,28 @@ return static function (RouteCollectorProxy $group) {
|
|||
/*
|
||||
* Files/Media
|
||||
*/
|
||||
|
||||
$group->get('/quota[/{type}]', Controller\Api\Stations\GetQuotaAction::class)
|
||||
->setName('api:stations:quota')
|
||||
->add(new Middleware\Permissions(StationPermissions::View, true));
|
||||
|
||||
$group->get(
|
||||
'/waveform/{media_id:[a-zA-Z0-9\-]+}.json',
|
||||
Controller\Api\Stations\Waveform\GetWaveformAction::class
|
||||
)->setName('api:stations:media:waveform');
|
||||
|
||||
$group->get('/art/{media_id:[a-zA-Z0-9\-]+}.jpg', Controller\Api\Stations\Art\GetArtAction::class)
|
||||
->setName('api:stations:media:art');
|
||||
|
||||
$group->get('/art/{media_id:[a-zA-Z0-9\-]+}', Controller\Api\Stations\Art\GetArtAction::class)
|
||||
->setName('api:stations:media:art-internal');
|
||||
|
||||
$group->post('/art/{media_id:[a-zA-Z0-9]+}', Controller\Api\Stations\Art\PostArtAction::class)
|
||||
->add(new Middleware\Permissions(StationPermissions::Media, true));
|
||||
|
||||
$group->delete('/art/{media_id:[a-zA-Z0-9]+}', Controller\Api\Stations\Art\DeleteArtAction::class)
|
||||
->add(new Middleware\Permissions(StationPermissions::Media, true));
|
||||
|
||||
$group->group(
|
||||
'',
|
||||
function (RouteCollectorProxy $group) {
|
||||
|
@ -561,6 +564,15 @@ return static function (RouteCollectorProxy $group) {
|
|||
/*
|
||||
* Reports
|
||||
*/
|
||||
|
||||
$group->get('/history', Controller\Api\Stations\HistoryController::class)
|
||||
->setName('api:stations:history')
|
||||
->add(new Middleware\Permissions(StationPermissions::Reports, true));
|
||||
|
||||
$group->get('/listeners', Controller\Api\Stations\ListenersAction::class)
|
||||
->setName('api:listeners:index')
|
||||
->add(new Middleware\Permissions(StationPermissions::Reports, true));
|
||||
|
||||
$group->group(
|
||||
'/reports',
|
||||
function (RouteCollectorProxy $group) {
|
||||
|
@ -627,7 +639,7 @@ return static function (RouteCollectorProxy $group) {
|
|||
)->add(new Middleware\Permissions(StationPermissions::Reports, true));
|
||||
|
||||
/*
|
||||
* Streamers Extras
|
||||
* Streamers
|
||||
*/
|
||||
$group->get(
|
||||
'/streamer/{id}/art',
|
||||
|
|
|
@ -80,12 +80,6 @@ final class RequestsController
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
// Verify that the station supports requests.
|
||||
if (!$station->getBackendTypeEnum()->isEnabled() || !$station->getEnableRequests()) {
|
||||
return $response->withStatus(403)
|
||||
->withJson(new Entity\Api\Error(403, __('This station does not accept requests currently.')));
|
||||
}
|
||||
|
||||
$playlistIds = $this->getRequestablePlaylists($station);
|
||||
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
|
@ -188,12 +182,6 @@ final class RequestsController
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
// Verify that the station supports requests.
|
||||
if (!$station->getBackendTypeEnum()->isEnabled() || !$station->getEnableRequests()) {
|
||||
return $response->withStatus(403)
|
||||
->withJson(new Entity\Api\Error(403, __('This station does not accept requests currently.')));
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $request->getUser();
|
||||
} catch (Exception\InvalidRequestAttribute) {
|
||||
|
|
|
@ -5,10 +5,10 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity;
|
||||
use App\Enums\StationFeatures;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Media\MimeType;
|
||||
use App\Service\SftpGo;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -61,7 +61,7 @@ final class FilesAction
|
|||
'customFields' => $this->customFieldRepo->fetchArray(),
|
||||
'validMimeTypes' => MimeType::getProcessableTypes(),
|
||||
'stationTimeZone' => $station->getTimezone(),
|
||||
'showSftp' => SftpGo::isSupportedForStation($station),
|
||||
'showSftp' => StationFeatures::Sftp->supportedForStation($station),
|
||||
'sftpUrl' => (string)$router->fromHere('stations:sftp_users:index'),
|
||||
'supportsImmediateQueue' => $backendEnum->isEnabled(),
|
||||
],
|
||||
|
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Exception;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -24,10 +23,6 @@ final class PlaylistsAction
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
if (!$station->getBackendTypeEnum()->isEnabled()) {
|
||||
throw new Exception(__('This feature is not currently supported on this station.'));
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$router = $request->getRouter();
|
||||
|
||||
|
|
|
@ -5,11 +5,9 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Environment;
|
||||
use App\Exception\StationUnsupportedException;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use App\Service\SftpGo;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class SftpUsersAction
|
||||
|
@ -25,12 +23,6 @@ final class SftpUsersAction
|
|||
Response $response,
|
||||
string $station_id
|
||||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
if (!SftpGo::isSupportedForStation($station)) {
|
||||
throw new StationUnsupportedException(__('This feature is not currently supported on this station.'));
|
||||
}
|
||||
|
||||
$baseUrl = $request->getRouter()->getBaseUrl()
|
||||
->withScheme('sftp')
|
||||
->withPort(null);
|
||||
|
|
|
@ -5,10 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity;
|
||||
use App\Exception\StationUnsupportedException;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Adapters;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -16,8 +14,7 @@ final class StreamersAction
|
|||
{
|
||||
public function __construct(
|
||||
private readonly AzuraCastCentral $acCentral,
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
||||
private readonly Adapters $adapters,
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -27,11 +24,6 @@ final class StreamersAction
|
|||
string $station_id
|
||||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
$backend = $this->adapters->getBackendAdapter($station);
|
||||
|
||||
if (null === $backend || !$station->getEnableStreamers()) {
|
||||
throw new StationUnsupportedException();
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$backendConfig = $station->getBackendConfig();
|
||||
|
@ -50,7 +42,7 @@ final class StreamersAction
|
|||
'stationTimeZone' => $station->getTimezone(),
|
||||
'connectionInfo' => [
|
||||
'serverUrl' => $settings->getBaseUrl(),
|
||||
'streamPort' => $backend->getStreamPort($station),
|
||||
'streamPort' => $backendConfig->getDjPort(),
|
||||
'ip' => $this->acCentral->getIp(),
|
||||
'djMountPoint' => $backendConfig->getDjMountPoint(),
|
||||
],
|
||||
|
|
|
@ -17,6 +17,7 @@ enum StationFeatures
|
|||
case Streamers;
|
||||
case Webhooks;
|
||||
case Podcasts;
|
||||
case Requests;
|
||||
|
||||
public function supportedForStation(Station $station): bool
|
||||
{
|
||||
|
@ -28,6 +29,7 @@ enum StationFeatures
|
|||
self::Sftp => $backendEnabled && $station->getMediaStorageLocation()->isLocal(),
|
||||
self::MountPoints => $station->getFrontendTypeEnum()->supportsMounts(),
|
||||
self::HlsStreams => $backendEnabled && $station->getEnableHls(),
|
||||
self::Requests => $backendEnabled && $station->getEnableRequests(),
|
||||
self::Webhooks, self::Podcasts => true,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Station;
|
||||
|
||||
class SftpGo
|
||||
{
|
||||
public static function isSupportedForStation(Station $station): bool
|
||||
{
|
||||
return $station->getMediaStorageLocation()->isLocal();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue