Реализовать lab3 в общем Helm-релизе с Traefik, TLS и HPA

This commit is contained in:
Vladislav Agapov
2026-10-16 11:51:20 +03:00
parent a57cbcf329
commit 9494547300
88 changed files with 1922 additions and 255 deletions
+20 -5
View File
@@ -37,13 +37,28 @@ func prepareChat(request dto.ChatsCreateRequestDTO, caller uuid.UUID) (dto.ChatD
// prepareMessage validates text and creates a record for the authorized sender and chat.
func prepareMessage(request dto.MessagesCreateRequestDTO, sender, chatID uuid.UUID) (dto.MessageDTO, error) {
if !validText(request.Text, maxMessageRunes) {
if !validText(request.Text, maxMessageRunes) || !validIdempotencyKey(request.IdempotencyKey) {
return dto.MessageDTO{}, service.ErrInvalid
}
return dto.MessageDTO{
ID: uuid.New(),
ChatID: chatID,
SenderID: sender,
Text: request.Text,
ID: uuid.New(),
ChatID: chatID,
SenderID: sender,
Text: request.Text,
IdempotencyKey: request.IdempotencyKey,
}, nil
}
// validIdempotencyKey accepts only the bounded ASCII alphabet from the contract.
func validIdempotencyKey(key string) bool {
if len(key) < 1 || len(key) > 128 {
return false
}
for _, c := range key {
if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '.' || c == '_' || c == ':' || c == '-' {
continue
}
return false
}
return true
}