fix: improved Spotify auth check flow, refs NOISSUE
This commit is contained in:
		@@ -87,21 +87,23 @@ likePlaylistCheckTimer.OnOccurence += async (s, ea) =>
 | 
				
			|||||||
        if (!await spotifyApiClient.IsUserAuthenticatedAsync(user))
 | 
					        if (!await spotifyApiClient.IsUserAuthenticatedAsync(user))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            logger.LogWarning($"User {user.LdapUserName} is not authorized with Spotify - skipping playlist sync");
 | 
					            logger.LogWarning($"User {user.LdapUserName} is not authorized with Spotify - skipping playlist sync");
 | 
				
			||||||
            continue;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        var foundPlaylist = dci.SmartPlaylistDefinitions?.Where(p => p.CreatedBy == user).ToList().Where(p => p.IsThisUsersLikedSongsPlaylist).SingleOrDefault();
 | 
					        else
 | 
				
			||||||
        if (foundPlaylist == null)
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            logger.LogWarning($"Creating liked songs playlist for user {user.LdapUserName}");
 | 
					            var foundPlaylist = dci.SmartPlaylistDefinitions?.Where(p => p.CreatedBy == user).ToList().Where(p => p.IsThisUsersLikedSongsPlaylist).SingleOrDefault();
 | 
				
			||||||
            var title = $"{user.PreferredName}'s liked songs";
 | 
					            if (foundPlaylist == null)
 | 
				
			||||||
            var description = $"A collection of the songs liked by {user.PreferredName} on their 'Song of the day' server instance.";
 | 
					            {
 | 
				
			||||||
            // playlist does not exist yet, creating it
 | 
					                logger.LogWarning($"Creating liked songs playlist for user {user.LdapUserName}");
 | 
				
			||||||
            var newPlaylist = await (await spotifyApiClient.WithUserAuthorizationAsync(user)).CreateSpotifyPlaylist(title, description, false, true, user);
 | 
					                var title = $"{user.PreferredName}'s liked songs";
 | 
				
			||||||
            await playlistSynchronizer.SynchronizePlaylistAsync(newPlaylist);
 | 
					                var description = $"A collection of the songs liked by {user.PreferredName} on their 'Song of the day' server instance.";
 | 
				
			||||||
            needsSaving = true;
 | 
					                // playlist does not exist yet, creating it
 | 
				
			||||||
 | 
					                var newPlaylist = await (await spotifyApiClient.WithUserAuthorizationAsync(user)).CreateSpotifyPlaylist(title, description, false, true, user);
 | 
				
			||||||
 | 
					                await playlistSynchronizer.SynchronizePlaylistAsync(newPlaylist);
 | 
				
			||||||
 | 
					                needsSaving = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            logger.LogWarning($"Syncing playlists for user {user.LdapUserName}");
 | 
				
			||||||
 | 
					            await playlistSynchronizer.SynchronizeUserPlaylistsAsync(user);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        logger.LogWarning($"Syncing playlists for user {user.LdapUserName}");
 | 
					 | 
				
			||||||
        await playlistSynchronizer.SynchronizeUserPlaylistsAsync(user);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (needsSaving)
 | 
					    if (needsSaving)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user