feat: attachments over S3 (grade 3)

This commit is contained in:
2026-11-20 03:55:39 +03:00
parent 083d0d80cc
commit 89e9e7b4d4
44 changed files with 1468 additions and 67 deletions
+14 -1
View File
@@ -3,6 +3,7 @@ package handler
import (
"net/http"
"regexp"
"uuid"
)
const headerIdempotencyKey = "Idempotency-Key"
@@ -29,7 +30,19 @@ func (h *Handler) SendMessage(w http.ResponseWriter, r *http.Request) {
h.fail(w, r, badRequest("text is required"))
return
}
msg, err := h.messages.Send(r.Context(), actor(r), chatID, key, *req.Text)
var attachmentIDs []uuid.UUID
if req.AttachmentIDs != nil {
attachmentIDs = make([]uuid.UUID, len(*req.AttachmentIDs))
for i, raw := range *req.AttachmentIDs {
id, ok := parseUUID(raw)
if !ok {
h.fail(w, r, badRequest("attachment_ids must contain UUIDs"))
return
}
attachmentIDs[i] = id
}
}
msg, err := h.messages.Send(r.Context(), actor(r), chatID, key, *req.Text, attachmentIDs)
if err != nil {
h.fail(w, r, err)
return