fix(attachment): check download variant and readiness

This commit is contained in:
kk10
2026-11-06 15:44:33 +03:00
parent a11463c680
commit bca081428a
4 changed files with 24 additions and 1 deletions
+11
View File
@@ -113,8 +113,19 @@ func (h *AttachmentHandler) GetContent(w http.ResponseWriter, r *http.Request) {
return
}
req := dto.GetAttachmentContentRequest{
Variant: r.URL.Query().Get("variant"),
}
if !req.Validate() {
httpx.WriteError(w, http.StatusNotFound, dto.ErrorCodeNotFound, "not found", requestID)
return
}
data, contentType, err := h.service.GetContent(r.Context(), userID, attachmentID)
switch {
case errors.Is(err, service.ErrAttachmentNotReady):
httpx.WriteError(w, http.StatusConflict, dto.ErrorCodeConflict, "attachment not ready", requestID)
return
case errors.Is(err, service.ErrAttachmentNotFound):
httpx.WriteError(w, http.StatusNotFound, dto.ErrorCodeNotFound, "not found", requestID)
return