Skip to content

Commit 91cc45d

Browse files
committed
Fix IsUploadAvatarChanged comparison
Use the correct function for hashing image data
1 parent bb6377d commit 91cc45d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

models/user/avatar.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package user
55

66
import (
77
"context"
8-
"crypto/md5"
98
"fmt"
109
"image/png"
1110
"io"
@@ -106,7 +105,7 @@ func (u *User) IsUploadAvatarChanged(data []byte) bool {
106105
if !u.UseCustomAvatar || len(u.Avatar) == 0 {
107106
return true
108107
}
109-
avatarID := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", u.ID, md5.Sum(data)))))
108+
avatarID := avatar.HashAvatar(u.ID, data)
110109
return u.Avatar != avatarID
111110
}
112111

0 commit comments

Comments
 (0)