forked from mtusi2026/mtusi2026lab4
feat: two-store reconciler with safe repair and cost measurement (grade 5, track 2)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"uuid"
|
||||
@@ -31,10 +33,19 @@ func (h *Handler) SendMessage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
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 len(req.AttachmentIDs) > 0 {
|
||||
if bytes.Equal(bytes.TrimSpace(req.AttachmentIDs), []byte("null")) {
|
||||
h.fail(w, r, badRequest("attachment_ids must be an array of UUIDs"))
|
||||
return
|
||||
}
|
||||
var raw []string
|
||||
if err := json.Unmarshal(req.AttachmentIDs, &raw); err != nil {
|
||||
h.fail(w, r, badRequest("attachment_ids must be an array of UUIDs"))
|
||||
return
|
||||
}
|
||||
attachmentIDs = make([]uuid.UUID, len(raw))
|
||||
for i, value := range raw {
|
||||
id, ok := parseUUID(value)
|
||||
if !ok {
|
||||
h.fail(w, r, badRequest("attachment_ids must contain UUIDs"))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user