Skip to content

Commit

Permalink
fix: avatar refreshing
Browse files Browse the repository at this point in the history
- Dumbass used the ID instead of username
  • Loading branch information
fvckgrimm committed Sep 23, 2024
1 parent edfa8a0 commit e6cbf43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (b *Bot) monitorUsers() {

// Check if avatar URL needs refreshing (e.g., older than 6 days)
if time.Now().Unix()-user.AvatarLocationUpdatedAt > 6*24*60*60 {
newAvatarLocation, err := b.refreshAvatarURL(user.UserID)
newAvatarLocation, err := b.refreshAvatarURL(user.Username)
if err != nil {
log.Printf("Error refreshing avatar URL for user %s: %v", user.Username, err)
} else {
Expand Down Expand Up @@ -238,14 +238,14 @@ func (b *Bot) retryDbOperation(operation func() error) error {
return fmt.Errorf("operation failed after %d retries", maxRetries)
}

func (b *Bot) refreshAvatarURL(userID string) (string, error) {
accountInfo, err := b.APIClient.GetAccountInfo(userID)
func (b *Bot) refreshAvatarURL(username string) (string, error) {
accountInfo, err := b.APIClient.GetAccountInfo(username)
if err != nil {
return "", err
}

if accountInfo == nil || accountInfo.Avatar.Locations == nil || len(accountInfo.Avatar.Variants) == 0 || len(accountInfo.Avatar.Variants[0].Locations) == 0 {
return "", fmt.Errorf("invalid account info structure for user %s", userID)
return "", fmt.Errorf("invalid account info structure for user %s", username)
}

return accountInfo.Avatar.Variants[0].Locations[0].Location, nil
Expand Down

0 comments on commit e6cbf43

Please sign in to comment.