code: func replaceAvatar(w http.ResponseWriter, r *http.Request, oldAvatar *user.Avatar,
  	newAvatar *user.Avatar, username string, userMgr *user.Manager) {
  	var err error
  	// If the old avatar points to a file on itsyou.online, we need to remove the file stored here.
  	if strings.HasPrefix(strings.TrimPrefix(oldAvatar.Source, "https://"), r.Host) {
  		hash := getAvatarHashFromLink(oldAvatar.Source)
  		err = userMgr.RemoveAvatarFile(hash)
  		if handleServerError(w, "removing avatar file", err) {
  			return
  		}
  	}
  
  	// now remove the old avatar
  	err = userMgr.RemoveAvatar(username, oldAvatar.Label)
  	if handleServerError(w, "removing old avatar", err) {
  		return
  	}
  
  	// insert the new avatar
  	err = userMgr.SaveAvatar(username, *newAvatar)
  	if handleServerError(w, "saving new avatar", err) {
  		return
  	}
  
  	w.WriteHeader(http.StatusOK)
  	json.NewEncoder(w).Encode(newAvatar)
  }
docs: // replaceAvatar replaces an old avatar with a new one. It also removes avatar
  // files stored on the server if the link is updated or a new file is uploaded