diff --git a/go/internal/handler/handler.go b/go/internal/handler/handler.go index 4ba55c3..4462820 100644 --- a/go/internal/handler/handler.go +++ b/go/internal/handler/handler.go @@ -342,18 +342,17 @@ func (h *Handler) DeleteAvatar(w http.ResponseWriter, r *http.Request) { return } - err := h.humanSvc.DeleteAvatar(r.Context(), humanId) + human, err := h.humanSvc.GetByID(r.Context(), humanId) if err != nil { - flog.Error("failed to delete avatar from human", "error", err) + flog.Error("failed to get human by id", "error", err, "humanId", humanId) http.Error(w, "internal server error", http.StatusInternalServerError) return } - // best-effort, gracefully continue - human, err := h.humanSvc.GetByID(r.Context(), humanId) + err := h.humanSvc.DeleteAvatar(r.Context(), humanId) if err != nil { - flog.Error("failed to get human by id", "error", err, "humanId", humanId) - w.WriteHeader(http.StatusNoContent) + flog.Error("failed to delete avatar from human", "error", err) + http.Error(w, "internal server error", http.StatusInternalServerError) return } @@ -401,6 +400,13 @@ func (h *Handler) UpdateAvatar(w http.ResponseWriter, r *http.Request) { if err != nil { flog.Error("failed to update human avatar", "error", err, "humanId", humanId) http.Error(w, "internal server error", http.StatusInternalServerError) + + // best effort + err = h.depotSvc.Delete(r.Context(), object.ID) + if err != nil { + flog.Error("best-effort delete of object failed", "error", err) + } + return }