2016-05-30 05:50:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Requests\API\ScrobbleRequest;
|
2020-04-27 18:55:12 +00:00
|
|
|
use App\Jobs\ScrobbleJob;
|
2016-05-30 05:50:59 +00:00
|
|
|
use App\Models\Song;
|
2020-09-13 22:04:07 +00:00
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2016-05-30 05:50:59 +00:00
|
|
|
|
|
|
|
class ScrobbleController extends Controller
|
|
|
|
{
|
2024-01-02 12:07:37 +00:00
|
|
|
/** @param User $user */
|
|
|
|
public function __invoke(ScrobbleRequest $request, Song $song, Authenticatable $user)
|
2018-08-19 21:17:05 +00:00
|
|
|
{
|
2024-01-02 12:07:37 +00:00
|
|
|
if (!$song->artist->is_unknown && $user->connectedToLastfm()) {
|
|
|
|
ScrobbleJob::dispatch($user, $song, $request->timestamp);
|
2018-08-19 21:17:05 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 17:07:43 +00:00
|
|
|
return response()->noContent();
|
2016-05-30 05:50:59 +00:00
|
|
|
}
|
|
|
|
}
|