Prepare verified laboratory 2 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:31:17 +03:00
parent 65003b6119
commit 62d7c2023c
85 changed files with 9426 additions and 38 deletions
+34
View File
@@ -0,0 +1,34 @@
package model
import (
"time"
"github.com/google/uuid"
)
const MaxMessageRunes = 4000
type Message struct {
ID uuid.UUID
ChatID uuid.UUID
SenderID uuid.UUID
Text string
CreatedAt time.Time
}
// MessageDraft — проверенное сообщение; отправитель берётся из идентификации,
// а не из тела запроса.
type MessageDraft struct {
ChatID uuid.UUID
SenderID uuid.UUID
Text string
}
func NewMessageDraft(chatID, senderID uuid.UUID, text string) (MessageDraft, error) {
if err := requireText("text", text, 1, MaxMessageRunes); err != nil {
return MessageDraft{}, err
}
return MessageDraft{ChatID: chatID, SenderID: senderID, Text: text}, nil
}
func (m Message) Position() Position { return Position{CreatedAt: m.CreatedAt, ID: m.ID} }