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

35 lines
990 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);
$this->authorize('access', $song);
2024-05-19 05:49:42 +00:00
$queueService->updatePlaybackStatus($user, $song, $request->position);
if ($song->isEpisode()) {
$podcastService->updateEpisodeProgress($user, $song, $request->position);
}
return response()->noContent();
}
}