enabled() public method

Determine if Last.fm integration is enabled.
public enabled ( ) : boolean
return boolean
Esempio n. 1
0
 /**
  * Handle the event.
  *
  * @param SongLikeToggled $event
  */
 public function handle(SongLikeToggled $event)
 {
     if (!$this->lastfm->enabled() || !($sessionKey = $event->user->lastfm_session_key) || $event->interaction->song->album->artist->isUnknown()) {
         return;
     }
     $this->lastfm->toggleLoveTrack($event->interaction->song->title, $event->interaction->song->album->artist->name, $sessionKey, $event->interaction->liked);
 }
Esempio n. 2
0
 /**
  * Handle the event.
  *
  * @param SongStartedPlaying $event
  */
 public function handle(SongStartedPlaying $event)
 {
     if (!$this->lastfm->enabled() || !($sessionKey = $event->user->getLastfmSessionKey()) || $event->song->album->artist->isUnknown()) {
         return;
     }
     $this->lastfm->updateNowPlaying($event->song->album->artist->name, $event->song->title, $event->song->album->name === Album::UNKNOWN_NAME ? null : $event->song->album->name, $event->song->length, $sessionKey);
 }
Esempio n. 3
0
 /**
  * Connect the current user to Last.fm.
  *
  * @param Redirector $redirector
  * @param Lastfm     $lastfm
  *
  * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function connect(Redirector $redirector, Lastfm $lastfm)
 {
     if (!$lastfm->enabled()) {
         abort(401, 'Koel is not configured to use with Last.fm yet.');
     }
     return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . route('lastfm.callback'));
 }
Esempio n. 4
0
 /**
  * Connect the current user to Last.fm.
  *
  * @param Redirector $redirector
  * @param Lastfm     $lastfm
  * @param JWTAuth    $auth
  *
  * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function connect(Redirector $redirector, Lastfm $lastfm, JWTAuth $auth = null)
 {
     abort_unless($lastfm->enabled(), 401, 'Koel is not configured to use with Last.fm yet.');
     $auth = $auth ?: $this->app['tymon.jwt.auth'];
     // A workaround to make sure Tymon's JWTAuth get the correct token via our custom
     // "jwt-token" query string instead of the default "token".
     // This is due to the problem that Last.fm returns the token via "token" as well.
     $auth->parseToken('', '', 'jwt-token');
     return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . urlencode(route('lastfm.callback') . '?jwt-token=' . $auth->getToken()));
 }