ЛР7 на 4: HTTPS, mTLS, OpenBao AppRole и ротация leaf.
Skeleton contracts / contracts (pull_request) Blocked by required conditions

Smoke/security/grade4/persistence/failover пройдены; REPORT и DEFENSE.
This commit is contained in:
2026-12-02 23:08:27 +03:00
parent 20afc2c790
commit 2f2047909f
182 changed files with 15169 additions and 90 deletions
+64
View File
@@ -0,0 +1,64 @@
package dto
import (
"gavrilenko-sxdees/lab7/internal/model"
"strings"
"time"
"unicode/utf8"
"github.com/google/uuid"
)
type CreateMessageRequest struct {
Text string `json:"text"`
AttachmentIDs []string `json:"attachment_ids"`
}
type MessageResponse struct {
ID uuid.UUID `json:"id"`
ChatID uuid.UUID `json:"chat_id"`
SenderID uuid.UUID `json:"sender_id"`
Text string `json:"text"`
AttachmentIDs []uuid.UUID `json:"attachment_ids"`
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.ContainsRune(r.Text, 0) || utf8.RuneCountInString(r.Text) > 4000 {
return false
}
if len(r.AttachmentIDs) > 10 {
return false
}
seen := make(map[string]struct{}, len(r.AttachmentIDs))
for _, id := range r.AttachmentIDs {
if _, ok := seen[id]; ok {
return false
}
seen[id] = struct{}{}
}
hasText := strings.TrimSpace(r.Text) != ""
hasAttachment := len(r.AttachmentIDs) > 0
return hasText || hasAttachment
}
func ToMessageResponse(m model.Message) MessageResponse {
ids := make([]uuid.UUID, len(m.AttachmentIDs))
copy(ids, m.AttachmentIDs)
return MessageResponse{
ID: m.ID,
ChatID: m.ChatID,
SenderID: m.SenderID,
Text: m.Text,
AttachmentIDs: ids,
CreatedAt: m.CreatedAt,
}
}