mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Convert getLastfmSessionKey() into attribute
This commit is contained in:
parent
76481a040b
commit
6b9ef7996a
5 changed files with 8 additions and 8 deletions
|
@ -32,7 +32,7 @@ class LoveTrackOnLastfm
|
|||
public function handle(SongLikeToggled $event)
|
||||
{
|
||||
if (!$this->lastfm->enabled() ||
|
||||
!($sessionKey = $event->user->getLastfmSessionKey()) ||
|
||||
!($sessionKey = $event->user->lastfm_session_key) ||
|
||||
$event->interaction->song->album->artist->isUnknown()
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -33,7 +33,7 @@ class UpdateLastfmNowPlaying
|
|||
public function handle(SongStartedPlaying $event)
|
||||
{
|
||||
if (!$this->lastfm->enabled() ||
|
||||
!($sessionKey = $event->user->getLastfmSessionKey()) ||
|
||||
!($sessionKey = $event->user->lastfm_session_key) ||
|
||||
$event->song->artist->isUnknown()
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -71,7 +71,7 @@ class Song extends Model
|
|||
}
|
||||
|
||||
// If the current user hasn't connected to Last.fm, don't do shit.
|
||||
if (!$sessionKey = auth()->user()->getLastfmSessionKey()) {
|
||||
if (!$sessionKey = auth()->user()->lastfm_session_key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function connectedToLastfm()
|
||||
{
|
||||
return (bool) $this->getLastfmSessionKey();
|
||||
return (bool) $this->lastfm_session_key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +124,7 @@ class User extends Authenticatable
|
|||
*
|
||||
* @return string|null The key if found, or null if user isn't connected to Last.fm
|
||||
*/
|
||||
public function getLastfmSessionKey()
|
||||
public function getLastfmSessionKeyAttribute()
|
||||
{
|
||||
return $this->getPreference('lastfm_session_key');
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ class LastfmTest extends TestCase
|
|||
{
|
||||
$user = factory(User::class)->create();
|
||||
$this->actingAs($user)->post('api/lastfm/session-key', ['key' => 'foo']);
|
||||
$this->assertEquals('foo', $user->getLastfmSessionKey());
|
||||
$this->assertEquals('foo', $user->lastfm_session_key);
|
||||
}
|
||||
|
||||
public function testControllerConnect()
|
||||
|
@ -160,14 +160,14 @@ class LastfmTest extends TestCase
|
|||
|
||||
(new LastfmController($guard))->callback($request, $lastfm);
|
||||
|
||||
$this->assertEquals('bar', $user->getLastfmSessionKey());
|
||||
$this->assertEquals('bar', $user->lastfm_session_key);
|
||||
}
|
||||
|
||||
public function testControllerDisconnect()
|
||||
{
|
||||
$user = factory(User::class)->create(['preferences' => ['lastfm_session_key' => 'bar']]);
|
||||
$this->actingAs($user)->delete('api/lastfm/disconnect');
|
||||
$this->assertNull($user->getLastfmSessionKey());
|
||||
$this->assertNull($user->lastfm_session_key);
|
||||
}
|
||||
|
||||
public function testLoveTrack()
|
||||
|
|
Loading…
Reference in a new issue