4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-14 21:26:37 +00:00
AzuraCast/src/Controller/Api/Stations/Art/DeleteArtAction.php

62 lines
1.7 KiB
PHP
Raw Normal View History

2019-10-11 01:22:02 +00:00
<?php
2021-07-19 05:53:45 +00:00
declare(strict_types=1);
2019-10-11 01:22:02 +00:00
namespace App\Controller\Api\Stations\Art;
use App\Entity;
use App\Http\Response;
use App\Http\ServerRequest;
use App\OpenApi;
use OpenApi\Attributes as OA;
2019-10-11 01:22:02 +00:00
use Psr\Http\Message\ResponseInterface;
#[OA\Delete(
path: '/station/{station_id}/art/{media_id}',
description: 'Removes the album art for a track.',
security: OpenApi::API_KEY_SECURITY,
tags: ['Stations: Media'],
parameters: [
2022-01-11 04:31:24 +00:00
new OA\Parameter(ref: OpenApi::REF_STATION_ID_REQUIRED),
new OA\Parameter(
name: 'id',
description: 'Media ID',
in: 'path',
required: true,
schema: new OA\Schema(
anyOf: [
new OA\Schema(type: 'integer', format: 'int64'),
new OA\Schema(type: 'string'),
]
)
),
],
responses: [
2022-01-11 04:31:24 +00:00
new OA\Response(ref: OpenApi::REF_RESPONSE_SUCCESS, response: 200),
new OA\Response(ref: OpenApi::REF_RESPONSE_ACCESS_DENIED, response: 403),
new OA\Response(ref: OpenApi::REF_RESPONSE_NOT_FOUND, response: 404),
new OA\Response(ref: OpenApi::REF_RESPONSE_GENERIC_ERROR, response: 500),
]
)]
final class DeleteArtAction
2019-10-11 01:22:02 +00:00
{
public function __construct(
private readonly Entity\Repository\StationMediaRepository $mediaRepo,
) {
}
2019-10-11 01:22:02 +00:00
public function __invoke(
ServerRequest $request,
Response $response,
2022-05-24 05:50:43 +00:00
string $station_id,
string $media_id
2019-10-11 01:22:02 +00:00
): ResponseInterface {
$station = $request->getStation();
$media = $this->mediaRepo->requireForStation($media_id, $station);
$this->mediaRepo->removeAlbumArt($media);
2019-10-11 01:22:02 +00:00
return $response->withJson(Entity\Api\Status::deleted());
2019-10-11 01:22:02 +00:00
}
}