Skip to content

Commit

Permalink
feat: use largest avatar from spotify instead (supabase#1210)
Browse files Browse the repository at this point in the history
Extracts the largest avatar returned by Spotify, instead of the first
avatar in the list.

Fixes:
- supabase#1209
  • Loading branch information
william-matz authored and LashaJini committed Nov 15, 2024
1 parent 299c61b commit 256bab6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/api/provider/spotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,17 @@ func (g spotifyProvider) GetUserData(ctx context.Context, tok *oauth2.Token) (*U

var avatarURL string

// Spotify returns a list of avatars, we want to use the largest one
if len(u.Avatars) >= 1 {
avatarURL = u.Avatars[0].Url
largestAvatar := u.Avatars[0]

for _, avatar := range u.Avatars {
if avatar.Height * avatar.Width > largestAvatar.Height * largestAvatar.Width {
largestAvatar = avatar
}
}

avatarURL = largestAvatar.Url
}

data.Metadata = &Claims{
Expand Down

0 comments on commit 256bab6

Please sign in to comment.