forked from mtusi2026/mtusi2026lab4
feat: attachments over S3 (grade 3)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user