Skip to content

Commit 3abea9e

Browse files
authored
Fix avatar bugs (#14217)
1 parent e6acce6 commit 3abea9e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

models/user_avatar.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ func (u *User) generateRandomAvatar(e Engine) error {
3939
return fmt.Errorf("RandomImage: %v", err)
4040
}
4141

42-
if u.Avatar == "" {
43-
u.Avatar = HashEmail(u.AvatarEmail)
44-
}
42+
u.Avatar = HashEmail(seed)
4543

44+
// Don't share the images so that we can delete them easily
4645
if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {
4746
if err := png.Encode(w, img); err != nil {
4847
log.Error("Encode: %v", err)
@@ -132,7 +131,7 @@ func (u *User) UploadAvatar(data []byte) error {
132131
// Otherwise, if any of the users delete his avatar
133132
// Other users will lose their avatars too.
134133
u.Avatar = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", u.ID, md5.Sum(data)))))
135-
if err = updateUser(sess, u); err != nil {
134+
if err = updateUserCols(sess, u, "use_custom_avatar", "avatar"); err != nil {
136135
return fmt.Errorf("updateUser: %v", err)
137136
}
138137

0 commit comments

Comments
 (0)