forked from mirrors/pronouns.cc
fix: delete current avatar when setting new avatar (fixes #33)
This commit is contained in:
parent
da67d12b60
commit
9813e1795e
2 changed files with 16 additions and 0 deletions
|
@ -190,6 +190,14 @@ func (s *Server) patchMember(w http.ResponseWriter, r *http.Request) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
avatarHash = &hash
|
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
|
return err
|
||||||
}
|
}
|
||||||
avatarHash = &hash
|
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 a new issue