fix(avatar): fallback to username when no name is set

This commit is contained in:
kolaente 2025-06-27 14:30:33 +02:00
parent 99bc065272
commit 59130766e8
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 5 additions and 1 deletions

View File

@ -143,7 +143,11 @@ func getAvatarForUser(u *user.User) (fullSizeAvatar *image.RGBA64, err error) {
if !exists {
log.Debugf("Initials avatar for user %d not cached, creating...", u.ID)
firstRune := []rune(strings.ToUpper(u.Name))[0]
avatarText := u.Name
if avatarText == "" {
avatarText = u.Username
}
firstRune := []rune(strings.ToUpper(avatarText))[0]
bg := avatarBgColors[int(u.ID)%len(avatarBgColors)] // Random color based on the user id
fullSizeAvatar, err = drawImage(firstRune, bg)