From 27b44ec79cfc776c601c1c6837f4b482c3709c4f Mon Sep 17 00:00:00 2001 From: An Phan Date: Sun, 5 Jun 2016 12:37:03 +0800 Subject: [PATCH] Refactor useLastfm config --- app/Http/Controllers/API/DataController.php | 3 ++- app/Http/routes.php | 3 +++ app/Services/Lastfm.php | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/API/DataController.php b/app/Http/Controllers/API/DataController.php index ec397cd2..9eb1f106 100644 --- a/app/Http/Controllers/API/DataController.php +++ b/app/Http/Controllers/API/DataController.php @@ -8,6 +8,7 @@ use App\Models\Interaction; use App\Models\Playlist; use App\Models\Setting; use App\Models\User; +use Lastfm; class DataController extends Controller { @@ -32,7 +33,7 @@ class DataController extends Controller 'interactions' => Interaction::byCurrentUser()->get(), 'users' => auth()->user()->is_admin ? User::all() : [], 'currentUser' => auth()->user(), - 'useLastfm' => env('LASTFM_API_KEY') && env('LASTFM_API_SECRET'), + 'useLastfm' => Lastfm::used(), 'allowDownload' => env('ALLOW_DOWNLOAD', true), 'cdnUrl' => app()->staticUrl(), 'currentVersion' => Application::VERSION, diff --git a/app/Http/routes.php b/app/Http/routes.php index 92febd74..627e5cc1 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -60,5 +60,8 @@ Route::group(['prefix' => 'api', 'namespace' => 'API'], function () { Route::get('playlist/{playlist}', 'PlaylistController@download'); Route::get('favorites', 'FavoritesController@download'); }); + + // Info routes + //if (Lastfm::used()) }); }); diff --git a/app/Services/Lastfm.php b/app/Services/Lastfm.php index bbfd89bf..d7d5c2b4 100644 --- a/app/Services/Lastfm.php +++ b/app/Services/Lastfm.php @@ -40,6 +40,16 @@ class Lastfm extends RESTfulService ); } + /** + * Determine if our application is using Last.fm. + * + * @return bool + */ + public function used() + { + return env('LASTFM_API_KEY') && env('LASTFM_API_SECRET'); + } + /** * Determine if Last.fm integration is enabled. *