package dto import ( "mtusi2026-messenger/internal/model" "strings" "time" "unicode/utf8" "github.com/google/uuid" ) type CreateMessageRequest struct { Text string `json:"text"` } type MessageResponse struct { ID uuid.UUID `json:"id"` ChatID uuid.UUID `json:"chat_id"` SenderID uuid.UUID `json:"sender_id"` Text string `json:"text"` CreatedAt time.Time `json:"created_at"` } type MessagePageResponse struct { Items []MessageResponse `json:"items"` NextCursor *string `json:"next_cursor"` } func (r CreateMessageRequest) Validate() bool { if strings.TrimSpace(r.Text) == "" || strings.ContainsRune(r.Text, 0) || utf8.RuneCountInString(r.Text) > 4000 { return false } return true } func ToMessageResponse(m model.Message) MessageResponse { return MessageResponse{ ID: m.ID, ChatID: m.ChatID, SenderID: m.SenderID, Text: m.Text, CreatedAt: m.CreatedAt, } }