User avatars seem to change color often #774

Closed
opened 2025-11-02 03:36:27 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @gayprogrammer on GitHub (Jun 5, 2017).

Originally assigned to: @lunny on GitHub.

  • Gitea version (or commit ref): 1.1.1+2-g2854c8a
  • Git version: 2.12.2
  • Operating system: Windows Server 2012
  • Database (use [x]):
    • MSSQL
  • Can you reproduce the bug at https://try.gitea.io:
    • Not relevant because avatars use Gravatar.
  • Log gist: Not relevant

User avatars seem to change color often. This is for auto-generated user avatars. I am in offline-mode and not using Gravatar.

Shapes in avatars remain the same. It seems I notice this almost daily. Is this a feature?

I would prefer color to stay consistent.

Originally created by @gayprogrammer on GitHub (Jun 5, 2017). Originally assigned to: @lunny on GitHub. - Gitea version (or commit ref): 1.1.1+2-g2854c8a - Git version: 2.12.2 - Operating system: Windows Server 2012 - Database (use `[x]`): - [x] MSSQL - Can you reproduce the bug at https://try.gitea.io: - [x] Not relevant because avatars use Gravatar. - Log gist: Not relevant User avatars seem to change color often. This is for auto-generated user avatars. I am in offline-mode and not using Gravatar. Shapes in avatars remain the same. It seems I notice this almost daily. Is this a feature? I would prefer color to stay consistent.
GiteaMirror added the type/bug label 2025-11-02 03:36:27 -06:00
Author
Owner

@dubeg commented on GitHub (Aug 8, 2017):

It is bugging me too.
I looked to find the cause, and this here seems to be the culprit: user.go#L863

This looks pretty hacky. I am not knowledgeable enough to move the block elsewhere. Can a contributor chime in on this?

@dubeg commented on GitHub (Aug 8, 2017): It is bugging me too. I looked to find the cause, and this here seems to be the culprit: [user.go#L863](https://github.com/go-gitea/gitea/blob/master/models/user.go#L863) This looks pretty hacky. I am not knowledgeable enough to move the block elsewhere. Can a contributor chime in on this?
Author
Owner

@lunny commented on GitHub (Aug 11, 2017):

@razzintown @dubeg have you tested v1.1.3 we release last days. I haven't reproduce the issue on that version.

@lunny commented on GitHub (Aug 11, 2017): @razzintown @dubeg have you tested v1.1.3 we release last days. I haven't reproduce the issue on that version.
Author
Owner

@dubeg commented on GitHub (Aug 11, 2017):

@lunny I downloaded 1.1.3 just to test it out. The bug still exists.

Steps to repro:

  1. Install Gitea.
    • Check the Disable Gravatar Service checkbox.
  2. Register your first user.
  3. Login as your first user.
    • Notice what your avatar looks like.
  4. Logout.
  5. Login again.
    • Notice that your avatar looks different.
    • The colors are most likely changed from the last time you logged in.

If at step 5, your avatar looks the same, then you lucked out. Try the steps again and you'll problably notice a differently colored avatar.

By the way, if I comment out or simply add a check before user.go#L863, the bug goes away. I'm pretty sure the fix could be to move the following block of code...

if !u.IsOrganization() {
	if len(u.AvatarEmail) == 0 {
		u.AvatarEmail = u.Email
	}
	u.Avatar = base.HashEmail(u.AvatarEmail)
}

... somewhere else. I don't think this code should be in the updateUser function. That function is called very often for many different reasons. There's no need to update the Avatar property everytime this method is called.

Instead, this block of code should be ran once at user creation, and perhaps also after avatar settings are updated. That said, there should be a check before the Avatar property is updated with the hash of the email: this should only be done if the Gravatar service is being used, I imagine. Alternatively, the files of the randomly-generated avatars could be named after the hash of the user's email address.

@dubeg commented on GitHub (Aug 11, 2017): @lunny I downloaded 1.1.3 just to test it out. The bug still exists. Steps to repro: 1. Install Gitea. - Check the `Disable Gravatar Service` checkbox. 2. Register your first user. 3. Login as your first user. - Notice what your avatar looks like. 4. Logout. 5. Login again. - Notice that your avatar looks different. - The colors are most likely changed from the last time you logged in. If at step 5, your avatar looks the same, then you lucked out. Try the steps again and you'll problably notice a differently colored avatar. By the way, if I comment out or simply add a check before [user.go#L863](https://github.com/go-gitea/gitea/blob/master/models/user.go#L863), the bug goes away. I'm pretty sure the fix could be to move the following block of code... ``` if !u.IsOrganization() { if len(u.AvatarEmail) == 0 { u.AvatarEmail = u.Email } u.Avatar = base.HashEmail(u.AvatarEmail) } ``` ... somewhere else. I don't think this code should be in the `updateUser` function. That function is called very often for many different reasons. There's no need to update the `Avatar` property everytime this method is called. Instead, this block of code should be ran once at user creation, and perhaps also after avatar settings are updated. That said, there should be a check before the `Avatar` property is updated with the hash of the email: this should only be done if the Gravatar service is being used, I imagine. Alternatively, the files of the randomly-generated avatars could be named after the hash of the user's email address.
Author
Owner

@lunny commented on GitHub (Aug 11, 2017):

@dubeg OK. I reproduced that.

@lunny commented on GitHub (Aug 11, 2017): @dubeg OK. I reproduced that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#774