diff --git a/app/Http/Controllers/API/LastfmController.php b/app/Http/Controllers/API/LastfmController.php index 2a034a1a..e17f180f 100644 --- a/app/Http/Controllers/API/LastfmController.php +++ b/app/Http/Controllers/API/LastfmController.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers\API; +use App\Services\Lastfm; use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; use Illuminate\Routing\Redirector; -use App\Services\Lastfm; class LastfmController extends Controller { diff --git a/app/Models/Song.php b/app/Models/Song.php index 95374ffc..9f3bf0eb 100644 --- a/app/Models/Song.php +++ b/app/Models/Song.php @@ -38,7 +38,7 @@ class Song extends Model * * @return mixed */ - public function scrobble($timestamp) + public function scrobble($timestamp) { // Don't scrobble the unknown guys. No one knows them. if ($this->album->artist->id === Artist::UNKNOWN_ID) { @@ -53,8 +53,8 @@ class Song extends Model } return Lastfm::scrobble( - $this->album->artist->name, - $this->title, + $this->album->artist->name, + $this->title, $timestamp, $this->album->name === Album::UNKNOWN_NAME ? '' : $this->album->name, $sessionKey diff --git a/app/Models/User.php b/app/Models/User.php index ade4ae2b..95288f00 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -85,7 +85,7 @@ AuthenticatableContract, $preferences = $this->preferences; $preferences[$key] = $val; $this->preferences = $preferences; - + $this->save(); } diff --git a/app/Services/Lastfm.php b/app/Services/Lastfm.php index 3fb2fe23..6b330e66 100644 --- a/app/Services/Lastfm.php +++ b/app/Services/Lastfm.php @@ -202,7 +202,7 @@ class Lastfm extends RESTfulService $params['method'] = 'track.scrobble'; try { - return !!$this->post('/', $this->buildAuthCallParams($params), false); + return (bool) $this->post('/', $this->buildAuthCallParams($params), false); } catch (\Exception $e) { Log::error($e); diff --git a/tests/LastfmTest.php b/tests/LastfmTest.php index bae68da2..23fa551e 100644 --- a/tests/LastfmTest.php +++ b/tests/LastfmTest.php @@ -1,15 +1,15 @@ '7f21233b54edea994aa0f23cf55f18a2', ], $api->buildAuthCallParams($params)); - $this->assertEquals('api_key=key&bar=baz&qux=安&api_sig=7f21233b54edea994aa0f23cf55f18a2', + $this->assertEquals('api_key=key&bar=baz&qux=安&api_sig=7f21233b54edea994aa0f23cf55f18a2', $api->buildAuthCallParams($params, true)); }