2015-12-20 12:17:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2017-12-09 18:34:27 +00:00
|
|
|
use App\Http\Requests\API\LastfmSetSessionKeyRequest;
|
2020-09-06 18:21:39 +00:00
|
|
|
use App\Models\User;
|
2021-06-04 16:19:34 +00:00
|
|
|
use App\Services\LastfmService;
|
2020-09-06 18:21:39 +00:00
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2015-12-20 12:17:35 +00:00
|
|
|
|
|
|
|
class LastfmController extends Controller
|
|
|
|
{
|
2022-07-29 06:47:10 +00:00
|
|
|
/** @param User $currentUser */
|
|
|
|
public function __construct(private LastfmService $lastfm, private ?Authenticatable $currentUser)
|
2018-09-04 06:25:24 +00:00
|
|
|
{
|
2015-12-20 12:17:35 +00:00
|
|
|
}
|
|
|
|
|
2017-12-09 18:34:27 +00:00
|
|
|
public function setSessionKey(LastfmSetSessionKeyRequest $request)
|
2016-01-26 06:32:29 +00:00
|
|
|
{
|
2022-07-29 06:47:10 +00:00
|
|
|
$this->lastfm->setUserSessionKey($this->currentUser, $request->key);
|
2016-01-26 06:32:29 +00:00
|
|
|
|
2021-12-06 17:07:43 +00:00
|
|
|
return response()->noContent();
|
2016-01-26 06:32:29 +00:00
|
|
|
}
|
|
|
|
|
2015-12-20 12:17:35 +00:00
|
|
|
public function disconnect()
|
|
|
|
{
|
2021-06-04 16:19:34 +00:00
|
|
|
$this->lastfm->setUserSessionKey($this->currentUser, null);
|
2018-09-04 02:25:34 +00:00
|
|
|
|
2021-12-06 17:07:43 +00:00
|
|
|
return response()->noContent();
|
2015-12-20 12:17:35 +00:00
|
|
|
}
|
|
|
|
}
|