fix: delete current avatar when setting new avatar (fixes #33)
This commit is contained in:
parent
da67d12b60
commit
9813e1795e
|
@ -190,6 +190,14 @@ func (s *Server) patchMember(w http.ResponseWriter, r *http.Request) error {
|
|||
return err
|
||||
}
|
||||
avatarHash = &hash
|
||||
|
||||
// delete current avatar if member has one
|
||||
if m.Avatar != nil {
|
||||
err = s.DB.DeleteMemberAvatar(ctx, claims.UserID, *m.Avatar)
|
||||
if err != nil {
|
||||
log.Errorf("deleting existing avatar: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,14 @@ func (s *Server) patchUser(w http.ResponseWriter, r *http.Request) error {
|
|||
return err
|
||||
}
|
||||
avatarHash = &hash
|
||||
|
||||
// delete current avatar if user has one
|
||||
if u.Avatar != nil {
|
||||
err = s.DB.DeleteUserAvatar(ctx, claims.UserID, *u.Avatar)
|
||||
if err != nil {
|
||||
log.Errorf("deleting existing avatar: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue