mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
chore: clean up and make code php8-y
This commit is contained in:
parent
2ac7b43830
commit
bfd1008f6c
118 changed files with 304 additions and 493 deletions
|
@ -15,16 +15,12 @@ class ChangePasswordCommand extends Command
|
||||||
{email? : The user's email. If empty, will get the default admin user.}";
|
{email? : The user's email. If empty, will get the default admin user.}";
|
||||||
protected $description = "Change a user's password";
|
protected $description = "Change a user's password";
|
||||||
|
|
||||||
private Hash $hash;
|
public function __construct(private Hash $hash)
|
||||||
|
|
||||||
public function __construct(Hash $hash)
|
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->hash = $hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$email = $this->argument('email');
|
$email = $this->argument('email');
|
||||||
|
|
||||||
|
@ -34,7 +30,7 @@ class ChangePasswordCommand extends Command
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->error('The user account cannot be found.');
|
$this->error('The user account cannot be found.');
|
||||||
|
|
||||||
return;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->comment("Changing the user's password (ID: $user->id, email: $user->email)");
|
$this->comment("Changing the user's password (ID: $user->id, email: $user->email)");
|
||||||
|
@ -43,5 +39,7 @@ class ChangePasswordCommand extends Command
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$this->comment('Alrighty, the new password has been saved. Enjoy! 👌');
|
$this->comment('Alrighty, the new password has been saved. Enjoy! 👌');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,6 @@ class ImportSearchableEntitiesCommand extends Command
|
||||||
$this->call('scout:import', ['model' => $entity]);
|
$this->call('scout:import', ['model' => $entity]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ class InitCommand extends Command
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$this->comment('Attempting to install or upgrade Koel.');
|
$this->comment('Attempting to install or upgrade Koel.');
|
||||||
$this->comment('Remember, you can always install/upgrade manually following the guide here:');
|
$this->comment('Remember, you can always install/upgrade manually following the guide here:');
|
||||||
|
@ -60,7 +60,7 @@ class InitCommand extends Command
|
||||||
$this->error('Please try again, or visit ' . config('koel.misc.docs_url') . ' for manual installation.');
|
$this->error('Please try again, or visit ' . config('koel.misc.docs_url') . ' for manual installation.');
|
||||||
$this->error('😥 Sorry for this. You deserve better.');
|
$this->error('😥 Sorry for this. You deserve better.');
|
||||||
|
|
||||||
return;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->comment(PHP_EOL . '🎆 Success! Koel can now be run from localhost with `php artisan serve`.');
|
$this->comment(PHP_EOL . '🎆 Success! Koel can now be run from localhost with `php artisan serve`.');
|
||||||
|
@ -76,12 +76,16 @@ class InitCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->comment('Again, visit 📙 ' . config('koel.misc.docs_url') . ' for the official documentation.');
|
$this->comment('Again, visit 📙 ' . config('koel.misc.docs_url') . ' for the official documentation.');
|
||||||
|
|
||||||
$this->comment(
|
$this->comment(
|
||||||
"Feeling generous and want to support Koel's development? Check out "
|
"Feeling generous and want to support Koel's development? Check out "
|
||||||
. config('koel.misc.sponsor_github_url')
|
. config('koel.misc.sponsor_github_url')
|
||||||
. ' 🤗'
|
. ' 🤗'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->comment('Thanks for using Koel. You rock! 🤘');
|
$this->comment('Thanks for using Koel. You rock! 🤘');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,6 @@ class PruneLibraryCommand extends Command
|
||||||
|
|
||||||
$this->info('Empty artists and albums removed.');
|
$this->info('Empty artists and albums removed.');
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class SyncCommand extends Command
|
||||||
$this->syncAll();
|
$this->syncAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,8 +9,10 @@ class TidyLibraryCommand extends Command
|
||||||
protected $signature = 'koel:tidy';
|
protected $signature = 'koel:tidy';
|
||||||
protected $hidden = true;
|
protected $hidden = true;
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$this->warn('koel:tidy has been renamed. Use koel:prune instead.');
|
$this->warn('koel:tidy has been renamed. Use koel:prune instead.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,7 @@ class MediaSyncCompleted extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public SyncResult $result;
|
public function __construct(public SyncResult $result)
|
||||||
|
|
||||||
public function __construct(SyncResult $result)
|
|
||||||
{
|
{
|
||||||
$this->result = $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,19 +3,13 @@
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Interaction;
|
use App\Models\Interaction;
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class SongLikeToggled extends Event
|
class SongLikeToggled extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public Interaction $interaction;
|
public function __construct(public Interaction $interaction)
|
||||||
public ?User $user = null;
|
|
||||||
|
|
||||||
public function __construct(Interaction $interaction, ?User $user = null)
|
|
||||||
{
|
{
|
||||||
$this->interaction = $interaction;
|
|
||||||
$this->user = $user ?: auth()->user();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,7 @@ class SongStartedPlaying extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public Song $song;
|
public function __construct(public Song $song, public User $user)
|
||||||
public User $user;
|
|
||||||
|
|
||||||
public function __construct(Song $song, User $user)
|
|
||||||
{
|
{
|
||||||
$this->song = $song;
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,7 @@ class SongsBatchLiked extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public Collection $songs;
|
public function __construct(public Collection $songs, public User $user)
|
||||||
public User $user;
|
|
||||||
|
|
||||||
public function __construct(Collection $songs, User $user)
|
|
||||||
{
|
{
|
||||||
$this->songs = $songs;
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,7 @@ class SongsBatchUnliked extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public Collection $songs;
|
public function __construct(public Collection $songs, public User $user)
|
||||||
public User $user;
|
|
||||||
|
|
||||||
public function __construct(Collection $songs, User $user)
|
|
||||||
{
|
{
|
||||||
$this->songs = $songs;
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,21 +11,12 @@ use App\Services\TranscodingService;
|
||||||
|
|
||||||
class StreamerFactory
|
class StreamerFactory
|
||||||
{
|
{
|
||||||
private DirectStreamerInterface $directStreamer;
|
|
||||||
private TranscodingStreamerInterface $transcodingStreamer;
|
|
||||||
private ObjectStorageStreamerInterface $objectStorageStreamer;
|
|
||||||
private TranscodingService $transcodingService;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DirectStreamerInterface $directStreamer,
|
private DirectStreamerInterface $directStreamer,
|
||||||
TranscodingStreamerInterface $transcodingStreamer,
|
private TranscodingStreamerInterface $transcodingStreamer,
|
||||||
ObjectStorageStreamerInterface $objectStorageStreamer,
|
private ObjectStorageStreamerInterface $objectStorageStreamer,
|
||||||
TranscodingService $transcodingService
|
private TranscodingService $transcodingService
|
||||||
) {
|
) {
|
||||||
$this->directStreamer = $directStreamer;
|
|
||||||
$this->transcodingStreamer = $transcodingStreamer;
|
|
||||||
$this->objectStorageStreamer = $objectStorageStreamer;
|
|
||||||
$this->transcodingService = $transcodingService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createStreamer(
|
public function createStreamer(
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
use App\Events\LibraryChanged;
|
use App\Events\LibraryChanged;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\AlbumCoverUpdateRequest;
|
use App\Http\Requests\API\AlbumCoverUpdateRequest;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
use App\Services\MediaMetadataService;
|
use App\Services\MediaMetadataService;
|
||||||
|
@ -10,11 +11,8 @@ use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
class AlbumCoverController extends Controller
|
class AlbumCoverController extends Controller
|
||||||
{
|
{
|
||||||
private MediaMetadataService $mediaMetadataService;
|
public function __construct(private MediaMetadataService $mediaMetadataService)
|
||||||
|
|
||||||
public function __construct(MediaMetadataService $mediaMetadataService)
|
|
||||||
{
|
{
|
||||||
$this->mediaMetadataService = $mediaMetadataService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(AlbumCoverUpdateRequest $request, Album $album)
|
public function update(AlbumCoverUpdateRequest $request, Album $album)
|
||||||
|
|
|
@ -2,17 +2,15 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
use App\Services\MediaMetadataService;
|
use App\Services\MediaMetadataService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
class AlbumThumbnailController extends Controller
|
class AlbumThumbnailController extends Controller
|
||||||
{
|
{
|
||||||
private MediaMetadataService $mediaMetadataService;
|
public function __construct(private MediaMetadataService $mediaMetadataService)
|
||||||
|
|
||||||
public function __construct(MediaMetadataService $mediaMetadataService)
|
|
||||||
{
|
{
|
||||||
$this->mediaMetadataService = $mediaMetadataService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Album $album): JsonResponse
|
public function show(Album $album): JsonResponse
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
use App\Events\LibraryChanged;
|
use App\Events\LibraryChanged;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\ArtistImageUpdateRequest;
|
use App\Http\Requests\API\ArtistImageUpdateRequest;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
use App\Services\MediaMetadataService;
|
use App\Services\MediaMetadataService;
|
||||||
|
@ -10,11 +11,8 @@ use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
class ArtistImageController extends Controller
|
class ArtistImageController extends Controller
|
||||||
{
|
{
|
||||||
private MediaMetadataService $mediaMetadataService;
|
public function __construct(private MediaMetadataService $mediaMetadataService)
|
||||||
|
|
||||||
public function __construct(MediaMetadataService $mediaMetadataService)
|
|
||||||
{
|
{
|
||||||
$this->mediaMetadataService = $mediaMetadataService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(ArtistImageUpdateRequest $request, Artist $artist)
|
public function update(ArtistImageUpdateRequest $request, Artist $artist)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\UserLoginRequest;
|
use App\Http\Requests\API\UserLoginRequest;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\UserRepository;
|
use App\Repositories\UserRepository;
|
||||||
|
@ -15,23 +16,13 @@ class AuthController extends Controller
|
||||||
{
|
{
|
||||||
use ThrottlesLogins;
|
use ThrottlesLogins;
|
||||||
|
|
||||||
private UserRepository $userRepository;
|
/** @param User $user */
|
||||||
private HashManager $hash;
|
|
||||||
private TokenManager $tokenManager;
|
|
||||||
|
|
||||||
/** @var User */
|
|
||||||
private ?Authenticatable $currentUser;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UserRepository $userRepository,
|
private UserRepository $userRepository,
|
||||||
HashManager $hash,
|
private HashManager $hash,
|
||||||
TokenManager $tokenManager,
|
private TokenManager $tokenManager,
|
||||||
?Authenticatable $currentUser
|
private ?Authenticatable $user
|
||||||
) {
|
) {
|
||||||
$this->userRepository = $userRepository;
|
|
||||||
$this->hash = $hash;
|
|
||||||
$this->tokenManager = $tokenManager;
|
|
||||||
$this->currentUser = $currentUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login(UserLoginRequest $request)
|
public function login(UserLoginRequest $request)
|
||||||
|
@ -50,8 +41,8 @@ class AuthController extends Controller
|
||||||
|
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
if ($this->currentUser) {
|
if ($this->user) {
|
||||||
$this->tokenManager->destroyTokens($this->currentUser);
|
$this->tokenManager->destroyTokens($this->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller as BaseController;
|
|
||||||
|
|
||||||
abstract class Controller extends BaseController
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\InteractionRepository;
|
use App\Repositories\InteractionRepository;
|
||||||
use App\Repositories\PlaylistRepository;
|
use App\Repositories\PlaylistRepository;
|
||||||
|
@ -18,41 +19,19 @@ class DataController extends Controller
|
||||||
{
|
{
|
||||||
private const RECENTLY_PLAYED_EXCERPT_COUNT = 7;
|
private const RECENTLY_PLAYED_EXCERPT_COUNT = 7;
|
||||||
|
|
||||||
private LastfmService $lastfmService;
|
/** @param User $currentUser */
|
||||||
private YouTubeService $youTubeService;
|
|
||||||
private ITunesService $iTunesService;
|
|
||||||
private MediaCacheService $mediaCacheService;
|
|
||||||
private SettingRepository $settingRepository;
|
|
||||||
private PlaylistRepository $playlistRepository;
|
|
||||||
private InteractionRepository $interactionRepository;
|
|
||||||
private UserRepository $userRepository;
|
|
||||||
private ApplicationInformationService $applicationInformationService;
|
|
||||||
|
|
||||||
/** @var User */
|
|
||||||
private ?Authenticatable $currentUser;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LastfmService $lastfmService,
|
private LastfmService $lastfmService,
|
||||||
YouTubeService $youTubeService,
|
private YouTubeService $youTubeService,
|
||||||
ITunesService $iTunesService,
|
private ITunesService $iTunesService,
|
||||||
MediaCacheService $mediaCacheService,
|
private MediaCacheService $mediaCacheService,
|
||||||
SettingRepository $settingRepository,
|
private SettingRepository $settingRepository,
|
||||||
PlaylistRepository $playlistRepository,
|
private PlaylistRepository $playlistRepository,
|
||||||
InteractionRepository $interactionRepository,
|
private InteractionRepository $interactionRepository,
|
||||||
UserRepository $userRepository,
|
private UserRepository $userRepository,
|
||||||
ApplicationInformationService $applicationInformationService,
|
private ApplicationInformationService $applicationInformationService,
|
||||||
?Authenticatable $currentUser
|
private ?Authenticatable $currentUser
|
||||||
) {
|
) {
|
||||||
$this->lastfmService = $lastfmService;
|
|
||||||
$this->youTubeService = $youTubeService;
|
|
||||||
$this->iTunesService = $iTunesService;
|
|
||||||
$this->mediaCacheService = $mediaCacheService;
|
|
||||||
$this->settingRepository = $settingRepository;
|
|
||||||
$this->playlistRepository = $playlistRepository;
|
|
||||||
$this->interactionRepository = $interactionRepository;
|
|
||||||
$this->userRepository = $userRepository;
|
|
||||||
$this->applicationInformationService = $applicationInformationService;
|
|
||||||
$this->currentUser = $currentUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
|
|
|
@ -2,10 +2,19 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\Interaction;
|
namespace App\Http\Controllers\API\Interaction;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\BatchInteractionRequest;
|
use App\Http\Requests\API\BatchInteractionRequest;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\InteractionService;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class BatchLikeController extends Controller
|
class BatchLikeController extends Controller
|
||||||
{
|
{
|
||||||
|
/** @param User $user */
|
||||||
|
public function __construct(private InteractionService $interactionService, protected ?Authenticatable $user)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function store(BatchInteractionRequest $request)
|
public function store(BatchInteractionRequest $request)
|
||||||
{
|
{
|
||||||
$interactions = $this->interactionService->batchLike((array) $request->songs, $this->user);
|
$interactions = $this->interactionService->batchLike((array) $request->songs, $this->user);
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\Interaction;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller as BaseController;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Services\InteractionService;
|
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
|
||||||
|
|
||||||
class Controller extends BaseController
|
|
||||||
{
|
|
||||||
protected InteractionService $interactionService;
|
|
||||||
|
|
||||||
/** @var User */
|
|
||||||
protected ?Authenticatable $user = null;
|
|
||||||
|
|
||||||
public function __construct(InteractionService $interactionService, ?Authenticatable $currentUser)
|
|
||||||
{
|
|
||||||
$this->interactionService = $interactionService;
|
|
||||||
$this->user = $currentUser;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,10 +2,19 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\Interaction;
|
namespace App\Http\Controllers\API\Interaction;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\SongLikeRequest;
|
use App\Http\Requests\API\SongLikeRequest;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\InteractionService;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class LikeController extends Controller
|
class LikeController extends Controller
|
||||||
{
|
{
|
||||||
|
/** @param User $user */
|
||||||
|
public function __construct(private InteractionService $interactionService, private ?Authenticatable $user)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function store(SongLikeRequest $request)
|
public function store(SongLikeRequest $request)
|
||||||
{
|
{
|
||||||
return response()->json($this->interactionService->toggleLike($request->song, $this->user));
|
return response()->json($this->interactionService->toggleLike($request->song, $this->user));
|
||||||
|
|
|
@ -3,10 +3,19 @@
|
||||||
namespace App\Http\Controllers\API\Interaction;
|
namespace App\Http\Controllers\API\Interaction;
|
||||||
|
|
||||||
use App\Events\SongStartedPlaying;
|
use App\Events\SongStartedPlaying;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\Interaction\StorePlayCountRequest;
|
use App\Http\Requests\API\Interaction\StorePlayCountRequest;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\InteractionService;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class PlayCountController extends Controller
|
class PlayCountController extends Controller
|
||||||
{
|
{
|
||||||
|
/** @param User $user */
|
||||||
|
public function __construct(private InteractionService $interactionService, private ?Authenticatable $user)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function store(StorePlayCountRequest $request)
|
public function store(StorePlayCountRequest $request)
|
||||||
{
|
{
|
||||||
$interaction = $this->interactionService->increasePlayCount($request->song, $this->user);
|
$interaction = $this->interactionService->increasePlayCount($request->song, $this->user);
|
||||||
|
|
|
@ -2,20 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\Interaction;
|
namespace App\Http\Controllers\API\Interaction;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\InteractionRepository;
|
use App\Repositories\InteractionRepository;
|
||||||
use App\Services\InteractionService;
|
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class RecentlyPlayedController extends Controller
|
class RecentlyPlayedController extends Controller
|
||||||
{
|
{
|
||||||
/** @param User $user */
|
/** @param User $user */
|
||||||
public function __construct(
|
public function __construct(private InteractionRepository $interactionRepository, private ?Authenticatable $user)
|
||||||
protected InteractionService $interactionService,
|
{
|
||||||
protected InteractionRepository $interactionRepository,
|
|
||||||
protected ?Authenticatable $user
|
|
||||||
) {
|
|
||||||
parent::__construct($interactionService, $user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(?int $count = null)
|
public function index(?int $count = null)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\LastfmSetSessionKeyRequest;
|
use App\Http\Requests\API\LastfmSetSessionKeyRequest;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\LastfmService;
|
use App\Services\LastfmService;
|
||||||
|
@ -9,20 +10,14 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class LastfmController extends Controller
|
class LastfmController extends Controller
|
||||||
{
|
{
|
||||||
private LastfmService $lastfm;
|
/** @param User $currentUser */
|
||||||
|
public function __construct(private LastfmService $lastfm, private ?Authenticatable $currentUser)
|
||||||
/** @var User */
|
|
||||||
private ?Authenticatable $currentUser;
|
|
||||||
|
|
||||||
public function __construct(LastfmService $lastfm, ?Authenticatable $currentUser)
|
|
||||||
{
|
{
|
||||||
$this->lastfm = $lastfm;
|
|
||||||
$this->currentUser = $currentUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSessionKey(LastfmSetSessionKeyRequest $request)
|
public function setSessionKey(LastfmSetSessionKeyRequest $request)
|
||||||
{
|
{
|
||||||
$this->lastfm->setUserSessionKey($this->currentUser, trim($request->key));
|
$this->lastfm->setUserSessionKey($this->currentUser, $request->key);
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\MediaInformation;
|
namespace App\Http\Controllers\API\MediaInformation;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
|
use App\Services\MediaInformationService;
|
||||||
|
|
||||||
class AlbumController extends Controller
|
class AlbumController extends Controller
|
||||||
{
|
{
|
||||||
|
public function __construct(private MediaInformationService $mediaInformationService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function show(Album $album)
|
public function show(Album $album)
|
||||||
{
|
{
|
||||||
return response()->json($this->mediaInformationService->getAlbumInformation($album)?->toArray() ?: []);
|
return response()->json($this->mediaInformationService->getAlbumInformation($album)?->toArray() ?: []);
|
||||||
|
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\MediaInformation;
|
namespace App\Http\Controllers\API\MediaInformation;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
|
use App\Services\MediaInformationService;
|
||||||
|
|
||||||
class ArtistController extends Controller
|
class ArtistController extends Controller
|
||||||
{
|
{
|
||||||
|
public function __construct(private MediaInformationService $mediaInformationService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function show(Artist $artist)
|
public function show(Artist $artist)
|
||||||
{
|
{
|
||||||
return response()->json($this->mediaInformationService->getArtistInformation($artist)?->toArray() ?: []);
|
return response()->json($this->mediaInformationService->getArtistInformation($artist)?->toArray() ?: []);
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\MediaInformation;
|
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller as BaseController;
|
|
||||||
use App\Services\MediaInformationService;
|
|
||||||
|
|
||||||
class Controller extends BaseController
|
|
||||||
{
|
|
||||||
protected MediaInformationService $mediaInformationService;
|
|
||||||
|
|
||||||
public function __construct(MediaInformationService $mediaInformationService)
|
|
||||||
{
|
|
||||||
$this->mediaInformationService = $mediaInformationService;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\MediaInformation;
|
namespace App\Http\Controllers\API\MediaInformation;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Song;
|
use App\Models\Song;
|
||||||
use App\Services\MediaInformationService;
|
use App\Services\MediaInformationService;
|
||||||
use App\Services\YouTubeService;
|
use App\Services\YouTubeService;
|
||||||
|
@ -9,10 +10,9 @@ use App\Services\YouTubeService;
|
||||||
class SongController extends Controller
|
class SongController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected MediaInformationService $mediaInformationService,
|
private MediaInformationService $mediaInformationService,
|
||||||
private YouTubeService $youTubeService
|
private YouTubeService $youTubeService
|
||||||
) {
|
) {
|
||||||
parent::__construct($mediaInformationService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Song $song)
|
public function show(Song $song)
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\ObjectStorage;
|
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller as BaseController;
|
|
||||||
|
|
||||||
class Controller extends BaseController
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\ObjectStorage\S3;
|
|
||||||
|
|
||||||
use App\Http\Controllers\API\ObjectStorage\Controller as BaseController;
|
|
||||||
|
|
||||||
class Controller extends BaseController
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers\API\ObjectStorage\S3;
|
namespace App\Http\Controllers\API\ObjectStorage\S3;
|
||||||
|
|
||||||
use App\Exceptions\SongPathNotFoundException;
|
use App\Exceptions\SongPathNotFoundException;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\ObjectStorage\S3\PutSongRequest;
|
use App\Http\Requests\API\ObjectStorage\S3\PutSongRequest;
|
||||||
use App\Http\Requests\API\ObjectStorage\S3\RemoveSongRequest;
|
use App\Http\Requests\API\ObjectStorage\S3\RemoveSongRequest;
|
||||||
use App\Services\S3Service;
|
use App\Services\S3Service;
|
||||||
|
@ -10,11 +11,8 @@ use Illuminate\Http\Response;
|
||||||
|
|
||||||
class SongController extends Controller
|
class SongController extends Controller
|
||||||
{
|
{
|
||||||
private S3Service $s3Service;
|
public function __construct(private S3Service $s3Service)
|
||||||
|
|
||||||
public function __construct(S3Service $s3Service)
|
|
||||||
{
|
{
|
||||||
$this->s3Service = $s3Service;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function put(PutSongRequest $request)
|
public function put(PutSongRequest $request)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\PlaylistStoreRequest;
|
use App\Http\Requests\API\PlaylistStoreRequest;
|
||||||
use App\Http\Requests\API\PlaylistUpdateRequest;
|
use App\Http\Requests\API\PlaylistUpdateRequest;
|
||||||
use App\Models\Playlist;
|
use App\Models\Playlist;
|
||||||
|
@ -12,20 +13,12 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class PlaylistController extends Controller
|
class PlaylistController extends Controller
|
||||||
{
|
{
|
||||||
private PlaylistRepository $playlistRepository;
|
/** @param User $user */
|
||||||
private PlaylistService $playlistService;
|
|
||||||
|
|
||||||
/** @var User */
|
|
||||||
private ?Authenticatable $currentUser;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PlaylistRepository $playlistRepository,
|
private PlaylistRepository $playlistRepository,
|
||||||
PlaylistService $playlistService,
|
private PlaylistService $playlistService,
|
||||||
?Authenticatable $currentUser
|
private ?Authenticatable $user
|
||||||
) {
|
) {
|
||||||
$this->playlistRepository = $playlistRepository;
|
|
||||||
$this->playlistService = $playlistService;
|
|
||||||
$this->currentUser = $currentUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
|
@ -37,7 +30,7 @@ class PlaylistController extends Controller
|
||||||
{
|
{
|
||||||
$playlist = $this->playlistService->createPlaylist(
|
$playlist = $this->playlistService->createPlaylist(
|
||||||
$request->name,
|
$request->name,
|
||||||
$this->currentUser,
|
$this->user,
|
||||||
(array) $request->songs,
|
(array) $request->songs,
|
||||||
$request->rules
|
$request->rules
|
||||||
);
|
);
|
||||||
|
@ -62,6 +55,6 @@ class PlaylistController extends Controller
|
||||||
|
|
||||||
$playlist->delete();
|
$playlist->delete();
|
||||||
|
|
||||||
return response()->json();
|
return response()->noContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,18 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\PlaylistSongUpdateRequest;
|
use App\Http\Requests\API\PlaylistSongUpdateRequest;
|
||||||
use App\Models\Playlist;
|
use App\Models\Playlist;
|
||||||
|
use App\Services\PlaylistService;
|
||||||
use App\Services\SmartPlaylistService;
|
use App\Services\SmartPlaylistService;
|
||||||
|
|
||||||
class PlaylistSongController extends Controller
|
class PlaylistSongController extends Controller
|
||||||
{
|
{
|
||||||
private SmartPlaylistService $smartPlaylistService;
|
public function __construct(
|
||||||
|
private SmartPlaylistService $smartPlaylistService,
|
||||||
public function __construct(SmartPlaylistService $smartPlaylistService)
|
private PlaylistService $playlistService
|
||||||
{
|
) {
|
||||||
$this->smartPlaylistService = $smartPlaylistService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Playlist $playlist)
|
public function index(Playlist $playlist)
|
||||||
|
@ -26,14 +27,15 @@ class PlaylistSongController extends Controller
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
public function update(PlaylistSongUpdateRequest $request, Playlist $playlist)
|
public function update(PlaylistSongUpdateRequest $request, Playlist $playlist)
|
||||||
{
|
{
|
||||||
$this->authorize('owner', $playlist);
|
$this->authorize('owner', $playlist);
|
||||||
|
|
||||||
abort_if($playlist->is_smart, 403, 'A smart playlist\'s content cannot be updated manually.');
|
abort_if($playlist->is_smart, 403, 'A smart playlist cannot be populated manually.');
|
||||||
|
|
||||||
$playlist->songs()->sync((array) $request->songs);
|
$this->playlistService->populatePlaylist($playlist, (array) $request->songs);
|
||||||
|
|
||||||
return response()->json();
|
return response()->noContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\ProfileUpdateRequest;
|
use App\Http\Requests\API\ProfileUpdateRequest;
|
||||||
use App\Http\Resources\UserResource;
|
use App\Http\Resources\UserResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\ScrobbleStoreRequest;
|
use App\Http\Requests\API\ScrobbleStoreRequest;
|
||||||
use App\Jobs\ScrobbleJob;
|
use App\Jobs\ScrobbleJob;
|
||||||
use App\Models\Song;
|
use App\Models\Song;
|
||||||
|
@ -10,12 +11,9 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class ScrobbleController extends Controller
|
class ScrobbleController extends Controller
|
||||||
{
|
{
|
||||||
/** @var User */
|
/** @param User $currentUser */
|
||||||
private ?Authenticatable $currentUser;
|
public function __construct(private ?Authenticatable $currentUser)
|
||||||
|
|
||||||
public function __construct(?Authenticatable $currentUser)
|
|
||||||
{
|
{
|
||||||
$this->currentUser = $currentUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(ScrobbleStoreRequest $request, Song $song)
|
public function store(ScrobbleStoreRequest $request, Song $song)
|
||||||
|
|
|
@ -2,31 +2,23 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\Search;
|
namespace App\Http\Controllers\API\Search;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Services\SearchService;
|
use App\Services\SearchService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class ExcerptSearchController extends Controller
|
class ExcerptSearchController extends Controller
|
||||||
{
|
{
|
||||||
private SearchService $searchService;
|
public function __construct(private SearchService $searchService)
|
||||||
|
|
||||||
public function __construct(SearchService $searchService)
|
|
||||||
{
|
{
|
||||||
$this->searchService = $searchService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
if (!$request->get('q')) {
|
throw_unless((bool) $request->get('q'), new InvalidArgumentException('A search query is required.'));
|
||||||
throw new InvalidArgumentException('A search query is required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = (int) $request->get('count', SearchService::DEFAULT_EXCERPT_RESULT_COUNT);
|
$count = (int) $request->get('count', SearchService::DEFAULT_EXCERPT_RESULT_COUNT);
|
||||||
|
throw_if($count < 0, new InvalidArgumentException('Invalid count parameter.'));
|
||||||
if ($count < 0) {
|
|
||||||
throw new InvalidArgumentException('Invalid count parameter.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'results' => $this->searchService->excerptSearch($request->get('q'), $count),
|
'results' => $this->searchService->excerptSearch($request->get('q'), $count),
|
||||||
|
|
|
@ -2,25 +2,20 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API\Search;
|
namespace App\Http\Controllers\API\Search;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Services\SearchService;
|
use App\Services\SearchService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class SongSearchController extends Controller
|
class SongSearchController extends Controller
|
||||||
{
|
{
|
||||||
private SearchService $searchService;
|
public function __construct(private SearchService $searchService)
|
||||||
|
|
||||||
public function __construct(SearchService $searchService)
|
|
||||||
{
|
{
|
||||||
$this->searchService = $searchService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
if (!$request->get('q')) {
|
throw_unless((bool) $request->get('q'), new InvalidArgumentException('A search query is required.'));
|
||||||
throw new InvalidArgumentException('A search query is required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'songs' => $this->searchService->searchSongs($request->get('q')),
|
'songs' => $this->searchService->searchSongs($request->get('q')),
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\SettingRequest;
|
use App\Http\Requests\API\SettingRequest;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\SongUpdateRequest;
|
use App\Http\Requests\API\SongUpdateRequest;
|
||||||
use App\Http\Resources\AlbumResource;
|
use App\Http\Resources\AlbumResource;
|
||||||
use App\Http\Resources\ArtistResource;
|
use App\Http\Resources\ArtistResource;
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
use App\Exceptions\MediaPathNotSetException;
|
use App\Exceptions\MediaPathNotSetException;
|
||||||
use App\Exceptions\SongUploadFailedException;
|
use App\Exceptions\SongUploadFailedException;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\UploadRequest;
|
use App\Http\Requests\API\UploadRequest;
|
||||||
use App\Http\Resources\AlbumResource;
|
use App\Http\Resources\AlbumResource;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\UserStoreRequest;
|
use App\Http\Requests\API\UserStoreRequest;
|
||||||
use App\Http\Requests\API\UserUpdateRequest;
|
use App\Http\Requests\API\UserUpdateRequest;
|
||||||
use App\Http\Resources\UserResource;
|
use App\Http\Resources\UserResource;
|
||||||
|
|
|
@ -2,17 +2,15 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\API;
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\YouTubeSearchRequest;
|
use App\Http\Requests\API\YouTubeSearchRequest;
|
||||||
use App\Models\Song;
|
use App\Models\Song;
|
||||||
use App\Services\YouTubeService;
|
use App\Services\YouTubeService;
|
||||||
|
|
||||||
class YouTubeController extends Controller
|
class YouTubeController extends Controller
|
||||||
{
|
{
|
||||||
private YouTubeService $youTubeService;
|
public function __construct(private YouTubeService $youTubeService)
|
||||||
|
|
||||||
public function __construct(YouTubeService $youTubeService)
|
|
||||||
{
|
{
|
||||||
$this->youTubeService = $youTubeService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchVideosRelatedToSong(YouTubeSearchRequest $request, Song $song)
|
public function searchVideosRelatedToSong(YouTubeSearchRequest $request, Song $song)
|
||||||
|
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Download;
|
namespace App\Http\Controllers\Download;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
|
use App\Services\DownloadService;
|
||||||
|
|
||||||
class AlbumController extends Controller
|
class AlbumController extends Controller
|
||||||
{
|
{
|
||||||
|
public function __construct(private DownloadService $downloadService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function show(Album $album)
|
public function show(Album $album)
|
||||||
{
|
{
|
||||||
return response()->download($this->downloadService->from($album));
|
return response()->download($this->downloadService->from($album));
|
||||||
|
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Download;
|
namespace App\Http\Controllers\Download;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
|
use App\Services\DownloadService;
|
||||||
|
|
||||||
class ArtistController extends Controller
|
class ArtistController extends Controller
|
||||||
{
|
{
|
||||||
|
public function __construct(private DownloadService $downloadService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function show(Artist $artist)
|
public function show(Artist $artist)
|
||||||
{
|
{
|
||||||
return response()->download($this->downloadService->from($artist));
|
return response()->download($this->downloadService->from($artist));
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Download;
|
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller as BaseController;
|
|
||||||
use App\Services\DownloadService;
|
|
||||||
|
|
||||||
abstract class Controller extends BaseController
|
|
||||||
{
|
|
||||||
protected DownloadService $downloadService;
|
|
||||||
|
|
||||||
public function __construct(DownloadService $downloadService)
|
|
||||||
{
|
|
||||||
$this->downloadService = $downloadService;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,24 +2,25 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Download;
|
namespace App\Http\Controllers\Download;
|
||||||
|
|
||||||
use App\Http\Requests\Download\Request;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
use App\Repositories\InteractionRepository;
|
use App\Repositories\InteractionRepository;
|
||||||
use App\Services\DownloadService;
|
use App\Services\DownloadService;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class FavoritesController extends Controller
|
class FavoritesController extends Controller
|
||||||
{
|
{
|
||||||
private InteractionRepository $interactionRepository;
|
/** @param User $user */
|
||||||
|
public function __construct(
|
||||||
public function __construct(DownloadService $downloadService, InteractionRepository $interactionRepository)
|
private DownloadService $downloadService,
|
||||||
{
|
private InteractionRepository $interactionRepository,
|
||||||
parent::__construct($downloadService);
|
private ?Authenticatable $user
|
||||||
|
) {
|
||||||
$this->interactionRepository = $interactionRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Request $request)
|
public function show()
|
||||||
{
|
{
|
||||||
$songs = $this->interactionRepository->getUserFavorites($request->user());
|
$songs = $this->interactionRepository->getUserFavorites($this->user);
|
||||||
|
|
||||||
return response()->download($this->downloadService->from($songs));
|
return response()->download($this->downloadService->from($songs));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Download;
|
namespace App\Http\Controllers\Download;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Playlist;
|
use App\Models\Playlist;
|
||||||
|
use App\Services\DownloadService;
|
||||||
|
|
||||||
class PlaylistController extends Controller
|
class PlaylistController extends Controller
|
||||||
{
|
{
|
||||||
|
public function __construct(private DownloadService $downloadService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function show(Playlist $playlist)
|
public function show(Playlist $playlist)
|
||||||
{
|
{
|
||||||
$this->authorize('owner', $playlist);
|
$this->authorize('owner', $playlist);
|
||||||
|
|
|
@ -2,19 +2,15 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Download;
|
namespace App\Http\Controllers\Download;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Download\SongRequest;
|
use App\Http\Requests\Download\SongRequest;
|
||||||
use App\Repositories\SongRepository;
|
use App\Repositories\SongRepository;
|
||||||
use App\Services\DownloadService;
|
use App\Services\DownloadService;
|
||||||
|
|
||||||
class SongController extends Controller
|
class SongController extends Controller
|
||||||
{
|
{
|
||||||
private SongRepository $songRepository;
|
public function __construct(private DownloadService $downloadService, private SongRepository $songRepository)
|
||||||
|
|
||||||
public function __construct(DownloadService $downloadService, SongRepository $songRepository)
|
|
||||||
{
|
{
|
||||||
parent::__construct($downloadService);
|
|
||||||
|
|
||||||
$this->songRepository = $songRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(SongRequest $request)
|
public function show(SongRequest $request)
|
||||||
|
|
|
@ -10,13 +10,8 @@ use Illuminate\Http\Response;
|
||||||
|
|
||||||
class ITunesController extends Controller
|
class ITunesController extends Controller
|
||||||
{
|
{
|
||||||
private ITunesService $iTunesService;
|
public function __construct(private ITunesService $iTunesService, private TokenManager $tokenManager)
|
||||||
private TokenManager $tokenManager;
|
|
||||||
|
|
||||||
public function __construct(ITunesService $iTunesService, TokenManager $tokenManager)
|
|
||||||
{
|
{
|
||||||
$this->iTunesService = $iTunesService;
|
|
||||||
$this->tokenManager = $tokenManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function viewSong(ViewSongOnITunesRequest $request, Album $album)
|
public function viewSong(ViewSongOnITunesRequest $request, Album $album)
|
||||||
|
|
|
@ -11,17 +11,12 @@ use Illuminate\Http\Response;
|
||||||
|
|
||||||
class LastfmController extends Controller
|
class LastfmController extends Controller
|
||||||
{
|
{
|
||||||
private LastfmService $lastfm;
|
/** @param User $currentUser */
|
||||||
private TokenManager $tokenManager;
|
public function __construct(
|
||||||
|
private LastfmService $lastfm,
|
||||||
/** @var User */
|
private TokenManager $tokenManager,
|
||||||
private ?Authenticatable $currentUser;
|
private ?Authenticatable $currentUser
|
||||||
|
) {
|
||||||
public function __construct(LastfmService $lastfm, TokenManager $tokenManager, ?Authenticatable $currentUser)
|
|
||||||
{
|
|
||||||
$this->lastfm = $lastfm;
|
|
||||||
$this->tokenManager = $tokenManager;
|
|
||||||
$this->currentUser = $currentUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function connect()
|
public function connect()
|
||||||
|
|
|
@ -8,17 +8,14 @@ use App\Models\Song;
|
||||||
|
|
||||||
class PlayController extends Controller
|
class PlayController extends Controller
|
||||||
{
|
{
|
||||||
private StreamerFactory $streamerFactory;
|
public function __construct(private StreamerFactory $streamerFactory)
|
||||||
|
|
||||||
public function __construct(StreamerFactory $streamerFactory)
|
|
||||||
{
|
{
|
||||||
$this->streamerFactory = $streamerFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(SongPlayRequest $request, Song $song, ?bool $transcode = null, ?int $bitRate = null)
|
public function show(SongPlayRequest $request, Song $song, ?bool $transcode = null, ?int $bitRate = null)
|
||||||
{
|
{
|
||||||
return $this->streamerFactory
|
return $this->streamerFactory
|
||||||
->createStreamer($song, $transcode, $bitRate, floatval($request->time))
|
->createStreamer($song, $transcode, $bitRate, (float) $request->time)
|
||||||
->stream();
|
->stream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\AlbumResource;
|
use App\Http\Resources\AlbumResource;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\ArtistResource;
|
use App\Http\Resources\ArtistResource;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\UserResource;
|
use App\Http\Resources\UserResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\PlaylistRepository;
|
use App\Repositories\PlaylistRepository;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Controllers\V6\Requests\SearchRequest;
|
use App\Http\Controllers\V6\Requests\SearchRequest;
|
||||||
use App\Http\Resources\ExcerptSearchResource;
|
use App\Http\Resources\ExcerptSearchResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\SongRepository;
|
use App\Repositories\SongRepository;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
use App\Services\MediaInformationService;
|
use App\Services\MediaInformationService;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
use App\Services\MediaInformationService;
|
use App\Services\MediaInformationService;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\AlbumResource;
|
use App\Http\Resources\AlbumResource;
|
||||||
use App\Http\Resources\ArtistResource;
|
use App\Http\Resources\ArtistResource;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
|
|
|
@ -3,12 +3,20 @@
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Events\SongStartedPlaying;
|
use App\Events\SongStartedPlaying;
|
||||||
use App\Http\Controllers\API\Interaction\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\API\Interaction\StorePlayCountRequest;
|
use App\Http\Requests\API\Interaction\StorePlayCountRequest;
|
||||||
use App\Http\Resources\InteractionResource;
|
use App\Http\Resources\InteractionResource;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\InteractionService;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
||||||
class PlayCountController extends Controller
|
class PlayCountController extends Controller
|
||||||
{
|
{
|
||||||
|
/** @param User $user */
|
||||||
|
public function __construct(private InteractionService $interactionService, private ?Authenticatable $user)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function store(StorePlayCountRequest $request)
|
public function store(StorePlayCountRequest $request)
|
||||||
{
|
{
|
||||||
$interaction = $this->interactionService->increasePlayCount($request->song, $this->user);
|
$interaction = $this->interactionService->increasePlayCount($request->song, $this->user);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Controllers\V6\Requests\AddSongsToPlaylistRequest;
|
use App\Http\Controllers\V6\Requests\AddSongsToPlaylistRequest;
|
||||||
use App\Http\Controllers\V6\Requests\RemoveSongsFromPlaylistRequest;
|
use App\Http\Controllers\V6\Requests\RemoveSongsFromPlaylistRequest;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Controllers\V6\Requests\QueueFetchSongRequest;
|
use App\Http\Controllers\V6\Requests\QueueFetchSongRequest;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\SongRepository;
|
use App\Repositories\SongRepository;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Controllers\V6\Requests\SongListRequest;
|
use App\Http\Controllers\V6\Requests\SongListRequest;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\Song;
|
use App\Models\Song;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\V6\API;
|
namespace App\Http\Controllers\V6\API;
|
||||||
|
|
||||||
use App\Http\Controllers\API\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Controllers\V6\Requests\SearchRequest;
|
use App\Http\Controllers\V6\Requests\SearchRequest;
|
||||||
use App\Http\Resources\SongResource;
|
use App\Http\Resources\SongResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
|
@ -8,11 +8,8 @@ use Illuminate\Http\Request;
|
||||||
|
|
||||||
class Authenticate
|
class Authenticate
|
||||||
{
|
{
|
||||||
protected Guard $auth;
|
public function __construct(protected Guard $auth)
|
||||||
|
|
||||||
public function __construct(Guard $auth)
|
|
||||||
{
|
{
|
||||||
$this->auth = $auth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
||||||
|
|
|
@ -8,11 +8,8 @@ use Illuminate\Routing\UrlGenerator;
|
||||||
|
|
||||||
class ForceHttps
|
class ForceHttps
|
||||||
{
|
{
|
||||||
private UrlGenerator $url;
|
public function __construct(private UrlGenerator $url)
|
||||||
|
|
||||||
public function __construct(UrlGenerator $url)
|
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate requests from Object Storage services (like S3).
|
* Authenticate requests from Object Storage services (like S3).
|
||||||
|
@ -13,9 +14,7 @@ class ObjectStorageAuthenticate
|
||||||
{
|
{
|
||||||
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
||||||
{
|
{
|
||||||
if ($request->appKey !== config('app.key')) {
|
abort_unless($request->get('appKey') === config('app.key'), Response::HTTP_UNAUTHORIZED);
|
||||||
return response('Unauthorized.', 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Http\Requests\API;
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
/** @property string $cover */
|
/** @property string $cover */
|
||||||
class AlbumCoverUpdateRequest extends AbstractMediaImageUpdateRequest
|
class AlbumCoverUpdateRequest extends MediaImageUpdateRequest
|
||||||
{
|
{
|
||||||
protected function getImageFieldName(): string
|
protected function getImageFieldName(): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Http\Requests\API;
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
/** @property string $image */
|
/** @property string $image */
|
||||||
class ArtistImageUpdateRequest extends AbstractMediaImageUpdateRequest
|
class ArtistImageUpdateRequest extends MediaImageUpdateRequest
|
||||||
{
|
{
|
||||||
protected function getImageFieldName(): string
|
protected function getImageFieldName(): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,6 @@ namespace App\Http\Requests\API\Interaction;
|
||||||
|
|
||||||
use App\Http\Requests\API\Request as BaseRequest;
|
use App\Http\Requests\API\Request as BaseRequest;
|
||||||
|
|
||||||
class Request extends BaseRequest
|
abstract class Request extends BaseRequest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Requests\API;
|
||||||
|
|
||||||
use App\Rules\ImageData;
|
use App\Rules\ImageData;
|
||||||
|
|
||||||
abstract class AbstractMediaImageUpdateRequest extends Request
|
abstract class MediaImageUpdateRequest extends Request
|
||||||
{
|
{
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Requests\API;
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
use App\Http\Requests\AbstractRequest;
|
use App\Http\Requests\Request as BaseRequest;
|
||||||
|
|
||||||
class Request extends AbstractRequest
|
abstract class Request extends BaseRequest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
namespace App\Http\Requests\API;
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
use App\Http\Requests\AbstractRequest;
|
use App\Http\Requests\Request;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
|
|
||||||
/** @property UploadedFile $file */
|
/** @property UploadedFile $file */
|
||||||
class UploadRequest extends AbstractRequest
|
class UploadRequest extends Request
|
||||||
{
|
{
|
||||||
/** @return array<mixed> */
|
/** @return array<mixed> */
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Requests\Download;
|
||||||
|
|
||||||
use App\Http\Requests\API\Request as BaseRequest;
|
use App\Http\Requests\API\Request as BaseRequest;
|
||||||
|
|
||||||
class Request extends BaseRequest
|
abstract class Request extends BaseRequest
|
||||||
{
|
{
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
abstract class AbstractRequest extends FormRequest
|
abstract class Request extends FormRequest
|
||||||
{
|
{
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
|
@ -3,9 +3,9 @@
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property float $time
|
* @property float|string $time
|
||||||
* @property string $api_token
|
* @property string $api_token
|
||||||
*/
|
*/
|
||||||
class SongPlayRequest extends AbstractRequest
|
class SongPlayRequest extends Request
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace App\Http\Requests;
|
||||||
* @property-read string $state
|
* @property-read string $state
|
||||||
* @property-read string $code
|
* @property-read string $code
|
||||||
*/
|
*/
|
||||||
class SpotifyCallbackRequest extends AbstractRequest
|
class SpotifyCallbackRequest extends Request
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,15 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
class LoveTrackOnLastfm implements ShouldQueue
|
class LoveTrackOnLastfm implements ShouldQueue
|
||||||
{
|
{
|
||||||
private LastfmService $lastfm;
|
public function __construct(private LastfmService $lastfm)
|
||||||
|
|
||||||
public function __construct(LastfmService $lastfm)
|
|
||||||
{
|
{
|
||||||
$this->lastfm = $lastfm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(SongLikeToggled $event): void
|
public function handle(SongLikeToggled $event): void
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
!$this->lastfm->enabled() ||
|
!$this->lastfm->enabled() ||
|
||||||
!$event->user->lastfm_session_key ||
|
!$event->interaction->user->lastfm_session_key ||
|
||||||
$event->interaction->song->artist->is_unknown
|
$event->interaction->song->artist->is_unknown
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
|
@ -28,7 +25,7 @@ class LoveTrackOnLastfm implements ShouldQueue
|
||||||
|
|
||||||
$this->lastfm->toggleLoveTrack(
|
$this->lastfm->toggleLoveTrack(
|
||||||
LastfmLoveTrackParameters::make($event->interaction->song->title, $event->interaction->song->artist->name),
|
LastfmLoveTrackParameters::make($event->interaction->song->title, $event->interaction->song->artist->name),
|
||||||
$event->user->lastfm_session_key,
|
$event->interaction->user->lastfm_session_key,
|
||||||
$event->interaction->liked
|
$event->interaction->liked
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,11 @@ class StreamerServiceProvider extends ServiceProvider
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
$this->app->bind(DirectStreamerInterface::class, static function (): DirectStreamerInterface {
|
$this->app->bind(DirectStreamerInterface::class, static function (): DirectStreamerInterface {
|
||||||
switch (config('koel.streaming.method')) {
|
return match (config('koel.streaming.method')) {
|
||||||
case 'x-sendfile':
|
'x-sendfile' => new XSendFileStreamer(),
|
||||||
return new XSendFileStreamer();
|
'x-accel-redirect' => new XAccelRedirectStreamer(),
|
||||||
|
default => new PhpStreamer(),
|
||||||
case 'x-accel-redirect':
|
};
|
||||||
return new XAccelRedirectStreamer();
|
|
||||||
|
|
||||||
default:
|
|
||||||
return new PhpStreamer();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->bind(TranscodingStreamerInterface::class, TranscodingStreamer::class);
|
$this->app->bind(TranscodingStreamerInterface::class, TranscodingStreamer::class);
|
||||||
|
|
|
@ -7,7 +7,7 @@ use App\Models\User;
|
||||||
use App\Repositories\Traits\Searchable;
|
use App\Repositories\Traits\Searchable;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class AlbumRepository extends AbstractRepository
|
class AlbumRepository extends Repository
|
||||||
{
|
{
|
||||||
use Searchable;
|
use Searchable;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use App\Models\User;
|
||||||
use App\Repositories\Traits\Searchable;
|
use App\Repositories\Traits\Searchable;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
class ArtistRepository extends AbstractRepository
|
class ArtistRepository extends Repository
|
||||||
{
|
{
|
||||||
use Searchable;
|
use Searchable;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use App\Repositories\Traits\ByCurrentUser;
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class InteractionRepository extends AbstractRepository
|
class InteractionRepository extends Repository
|
||||||
{
|
{
|
||||||
use ByCurrentUser;
|
use ByCurrentUser;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use App\Models\Playlist;
|
||||||
use App\Repositories\Traits\ByCurrentUser;
|
use App\Repositories\Traits\ByCurrentUser;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class PlaylistRepository extends AbstractRepository
|
class PlaylistRepository extends Repository
|
||||||
{
|
{
|
||||||
use ByCurrentUser;
|
use ByCurrentUser;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
abstract class AbstractRepository implements RepositoryInterface
|
abstract class Repository implements RepositoryInterface
|
||||||
{
|
{
|
||||||
private string $modelClass;
|
private string $modelClass;
|
||||||
protected Model $model;
|
protected Model $model;
|
|
@ -4,7 +4,7 @@ namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
|
||||||
class SettingRepository extends AbstractRepository
|
class SettingRepository extends Repository
|
||||||
{
|
{
|
||||||
/** @return array<mixed> */
|
/** @return array<mixed> */
|
||||||
public function getAllAsKeyValueArray(): array
|
public function getAllAsKeyValueArray(): array
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Illuminate\Contracts\Pagination\Paginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
class SongRepository extends AbstractRepository
|
class SongRepository extends Repository
|
||||||
{
|
{
|
||||||
use Searchable;
|
use Searchable;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
class UserRepository extends AbstractRepository
|
class UserRepository extends Repository
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use Webmozart\Assert\Assert;
|
||||||
* @method Promise headAsync($uri, array $data = [], bool $appendKey = true)
|
* @method Promise headAsync($uri, array $data = [], bool $appendKey = true)
|
||||||
* @method Promise deleteAsync($uri, array $data = [], bool $appendKey = true)
|
* @method Promise deleteAsync($uri, array $data = [], bool $appendKey = true)
|
||||||
*/
|
*/
|
||||||
abstract class AbstractApiClient
|
abstract class ApiClient
|
||||||
{
|
{
|
||||||
private const MAGIC_METHODS = [
|
private const MAGIC_METHODS = [
|
||||||
'get',
|
'get',
|
|
@ -11,15 +11,8 @@ class ApplicationInformationService
|
||||||
{
|
{
|
||||||
private const CACHE_KEY = 'latestKoelVersion';
|
private const CACHE_KEY = 'latestKoelVersion';
|
||||||
|
|
||||||
private Client $client;
|
public function __construct(private Client $client, private Cache $cache, private Logger $logger)
|
||||||
private Cache $cache;
|
|
||||||
private Logger $logger;
|
|
||||||
|
|
||||||
public function __construct(Client $client, Cache $cache, Logger $logger)
|
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
|
||||||
$this->cache = $cache;
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,40 +13,33 @@ use InvalidArgumentException;
|
||||||
|
|
||||||
class DownloadService
|
class DownloadService
|
||||||
{
|
{
|
||||||
private S3Service $s3Service;
|
public function __construct(private S3Service $s3Service)
|
||||||
|
|
||||||
public function __construct(S3Service $s3Service)
|
|
||||||
{
|
{
|
||||||
$this->s3Service = $s3Service;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic method to generate a download archive from various source types.
|
* Generic method to generate a download archive from various source types.
|
||||||
*
|
*
|
||||||
* @param Song|Collection|Album|Artist|Playlist $mixed
|
|
||||||
*
|
|
||||||
* @throws InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return string Full path to the generated archive
|
* @return string Full path to the generated archive
|
||||||
*/
|
*/
|
||||||
public function from($mixed): string
|
public function from(Playlist|Song|Album|Artist|Collection $downloadable): string
|
||||||
{
|
{
|
||||||
switch (get_class($mixed)) {
|
switch (get_class($downloadable)) {
|
||||||
case Song::class:
|
case Song::class:
|
||||||
return $this->fromSong($mixed);
|
return $this->fromSong($downloadable);
|
||||||
|
|
||||||
case Collection::class:
|
case Collection::class:
|
||||||
case EloquentCollection::class:
|
case EloquentCollection::class:
|
||||||
return $this->fromMultipleSongs($mixed);
|
return $this->fromMultipleSongs($downloadable);
|
||||||
|
|
||||||
case Album::class:
|
case Album::class:
|
||||||
return $this->fromAlbum($mixed);
|
return $this->fromAlbum($downloadable);
|
||||||
|
|
||||||
case Artist::class:
|
case Artist::class:
|
||||||
return $this->fromArtist($mixed);
|
return $this->fromArtist($downloadable);
|
||||||
|
|
||||||
case Playlist::class:
|
case Playlist::class:
|
||||||
return $this->fromPlaylist($mixed);
|
return $this->fromPlaylist($downloadable);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidArgumentException('Unsupported download type.');
|
throw new InvalidArgumentException('Unsupported download type.');
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Services;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class ITunesService extends AbstractApiClient implements ApiConsumerInterface
|
class ITunesService extends ApiClient implements ApiConsumerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determines whether to use iTunes services.
|
* Determines whether to use iTunes services.
|
||||||
|
|
|
@ -33,7 +33,7 @@ class InteractionService
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like or unlike a song on behalf of a user.
|
* Like or unlike a song as a user.
|
||||||
*
|
*
|
||||||
* @return Interaction the affected Interaction object
|
* @return Interaction the affected Interaction object
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,7 +13,7 @@ use GuzzleHttp\Promise\Utils;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class LastfmService extends AbstractApiClient implements ApiConsumerInterface
|
class LastfmService extends ApiClient implements ApiConsumerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Override the key param, since, again, Last.fm wants to be different.
|
* Override the key param, since, again, Last.fm wants to be different.
|
||||||
|
@ -143,8 +143,8 @@ class LastfmService extends AbstractApiClient implements ApiConsumerInterface
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->post('/', $this->buildAuthCallParams([
|
$this->post('/', $this->buildAuthCallParams([
|
||||||
'track' => $params->getTrackName(),
|
'track' => $params->trackName,
|
||||||
'artist' => $params->getArtistName(),
|
'artist' => $params->artistName,
|
||||||
'sk' => $sessionKey,
|
'sk' => $sessionKey,
|
||||||
'method' => $love ? 'track.love' : 'track.unlove',
|
'method' => $love ? 'track.love' : 'track.unlove',
|
||||||
]), false);
|
]), false);
|
||||||
|
@ -160,8 +160,8 @@ class LastfmService extends AbstractApiClient implements ApiConsumerInterface
|
||||||
{
|
{
|
||||||
$promises = $parameterCollection->map(
|
$promises = $parameterCollection->map(
|
||||||
fn (LastfmLoveTrackParameters $params): Promise => $this->postAsync('/', $this->buildAuthCallParams([
|
fn (LastfmLoveTrackParameters $params): Promise => $this->postAsync('/', $this->buildAuthCallParams([
|
||||||
'track' => $params->getTrackName(),
|
'track' => $params->trackName,
|
||||||
'artist' => $params->getArtistName(),
|
'artist' => $params->artistName,
|
||||||
'sk' => $sessionKey,
|
'sk' => $sessionKey,
|
||||||
'method' => $love ? 'track.love' : 'track.unlove',
|
'method' => $love ? 'track.love' : 'track.unlove',
|
||||||
]), false)
|
]), false)
|
||||||
|
|
|
@ -11,11 +11,8 @@ class MediaCacheService
|
||||||
{
|
{
|
||||||
private const CACHE_KEY = 'media_cache';
|
private const CACHE_KEY = 'media_cache';
|
||||||
|
|
||||||
private Cache $cache;
|
public function __construct(private Cache $cache)
|
||||||
|
|
||||||
public function __construct(Cache $cache)
|
|
||||||
{
|
{
|
||||||
$this->cache = $cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,4 +31,10 @@ class PlaylistService
|
||||||
{
|
{
|
||||||
$playlist->songs()->detach($songIds);
|
$playlist->songs()->detach($songIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
|
public function populatePlaylist(Playlist $playlist, array $songIds): void
|
||||||
|
{
|
||||||
|
$playlist->songs()->sync($songIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,18 +16,11 @@ class SearchService
|
||||||
{
|
{
|
||||||
public const DEFAULT_EXCERPT_RESULT_COUNT = 6;
|
public const DEFAULT_EXCERPT_RESULT_COUNT = 6;
|
||||||
|
|
||||||
private SongRepository $songRepository;
|
|
||||||
private AlbumRepository $albumRepository;
|
|
||||||
private ArtistRepository $artistRepository;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SongRepository $songRepository,
|
private SongRepository $songRepository,
|
||||||
AlbumRepository $albumRepository,
|
private AlbumRepository $albumRepository,
|
||||||
ArtistRepository $artistRepository
|
private ArtistRepository $artistRepository
|
||||||
) {
|
) {
|
||||||
$this->songRepository = $songRepository;
|
|
||||||
$this->albumRepository = $albumRepository;
|
|
||||||
$this->artistRepository = $artistRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return array<mixed> */
|
/** @return array<mixed> */
|
||||||
|
|
|
@ -26,12 +26,10 @@ class SongService
|
||||||
/** @var Song|null $song */
|
/** @var Song|null $song */
|
||||||
$song = Song::with('album', 'album.artist', 'artist')->find($id);
|
$song = Song::with('album', 'album.artist', 'artist')->find($id);
|
||||||
|
|
||||||
if (!$song) {
|
if ($song) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$updatedSongs->push($this->updateSong($song, $data));
|
$updatedSongs->push($this->updateSong($song, $data));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return $updatedSongs;
|
return $updatedSongs;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue