diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-03-08 23:05:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 23:05:15 +0800 |
commit | 5d40db629cb3a9ffdb7cdaa759f80c253c5ea428 (patch) | |
tree | 2386b045db24c3845fa8fdd77141e7b94cdd1f85 /models/user.go | |
parent | af9998b8a7b1db3d41783a115a2d0506bcba09d3 (diff) | |
download | gitea-5d40db629cb3a9ffdb7cdaa759f80c253c5ea428.tar.gz gitea-5d40db629cb3a9ffdb7cdaa759f80c253c5ea428.zip |
fix random avatars (#1147)
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go index fc78c5800f..54a60acd84 100644 --- a/models/user.go +++ b/models/user.go @@ -287,6 +287,10 @@ func (u *User) CustomAvatarPath() string { // GenerateRandomAvatar generates a random avatar for user. func (u *User) GenerateRandomAvatar() error { + return u.generateRandomAvatar(x) +} + +func (u *User) generateRandomAvatar(e Engine) error { seed := u.Email if len(seed) == 0 { seed = u.Name @@ -308,6 +312,10 @@ func (u *User) GenerateRandomAvatar() error { } defer fw.Close() + if _, err := e.Id(u.ID).Cols("avatar").Update(u); err != nil { + return err + } + if err = png.Encode(fw, img); err != nil { return fmt.Errorf("Encode: %v", err) } |