koel/app/Http/Controllers/API/UpdatePlaybackStatusController.php

33 lines
946 B
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Http\Requests\API\UpdatePlaybackStatusRequest;
use App\Models\User;
2024-05-19 05:49:42 +00:00
use App\Repositories\SongRepository;
use App\Services\PodcastService;
use App\Services\QueueService;
use Illuminate\Contracts\Auth\Authenticatable;
class UpdatePlaybackStatusController extends Controller
{
/** @param User $user */
2024-05-19 05:49:42 +00:00
public function __invoke(
UpdatePlaybackStatusRequest $request,
SongRepository $songRepository,
QueueService $queueService,
PodcastService $podcastService,
Authenticatable $user
) {
$song = $songRepository->getOne($request->song, $user);
$queueService->updatePlaybackStatus($user, $song, $request->position);
if ($song->isEpisode()) {
$podcastService->updateEpisodeProgress($user, $song, $request->position);
}
return response()->noContent();
}
}