lab5 done

This commit is contained in:
Khakimov Dmitrij
2026-11-10 22:13:40 +03:00
parent b2bd7501d3
commit cbe9d8748c
63 changed files with 8907 additions and 307 deletions
+10 -3
View File
@@ -33,7 +33,7 @@ func (h *Chat) uploadAttachment(c echo.Context) error {
if err != nil {
return h.useCaseError(c, err)
}
return c.JSON(http.StatusCreated, a)
return c.JSON(http.StatusAccepted, a)
}
func (h *Chat) getAttachment(c echo.Context) error {
a, err := h.attachments.Get(c.Request().Context(), c.Param("attachment_id"), authenticatedUser(c).ID)
@@ -51,8 +51,15 @@ func (h *Chat) attachmentContent(c echo.Context) error {
if err != nil {
return h.invalid(c, "Некорректный variant")
}
if present && variant != "original" {
return h.writeError(c, 404, "not_found", "Вариант не найден")
if a.Status != "ready" {
return h.writeError(c, 409, "conflict", "Вложение не готово")
}
if !present {
variant = "original"
}
a, err = h.attachments.Variant(a, variant)
if err != nil {
return h.useCaseError(c, err)
}
ctx, cancel := context.WithTimeout(c.Request().Context(), 45*time.Second)
defer cancel()
+3
View File
@@ -35,6 +35,9 @@ func (h *Chat) useCaseError(c echo.Context, err error) error {
switch applicationError.Code {
case "unsupported_media_type":
status = http.StatusUnsupportedMediaType
case "rate_limited":
status = http.StatusTooManyRequests
c.Response().Header().Set("Retry-After", "2")
case "payload_too_large":
status = http.StatusRequestEntityTooLarge
case domain.ErrorUnavailable: