catch no last refreshed time
This commit is contained in:
parent
3c248fd728
commit
731913c8c8
@ -42,24 +42,27 @@ def get_authed_spotify_network(user):
|
||||
access_token=user.access_token)
|
||||
user_obj.on_refresh.append(refresh_token_database_callback)
|
||||
|
||||
if user.last_refreshed is not None and user.token_expiry is not None:
|
||||
if user.last_refreshed + timedelta(seconds=user.token_expiry - 1) \
|
||||
< datetime.now(timezone.utc):
|
||||
user_obj.refresh_access_token()
|
||||
else:
|
||||
user_obj.refresh_access_token()
|
||||
|
||||
user_obj.refresh_info()
|
||||
return SpotifyNetwork(user_obj)
|
||||
else:
|
||||
logger.error('user spotify not linked')
|
||||
else:
|
||||
logger.error(f'user {user.username} not found')
|
||||
logger.error(f'no user provided')
|
||||
|
||||
|
||||
def get_authed_lastfm_network(user):
|
||||
if user:
|
||||
if user is not None:
|
||||
if user.lastfm_username:
|
||||
fm_keys = db.document('key/fm').get().to_dict()
|
||||
return FmNetwork(username=user.lastfm_username, api_key=fm_keys['clientid'])
|
||||
else:
|
||||
logger.error(f'{user.username} has no last.fm username')
|
||||
else:
|
||||
logger.error(f'user {user.username} not found')
|
||||
logger.error(f'no user provided')
|
||||
|
Loading…
Reference in New Issue
Block a user