validateOutboundBody runs the shared pre-send validation.
(subject, body string, to, cc, bcc []string, conversationID string)
| 353 | |
| 354 | // validateOutboundBody runs the shared pre-send validation. |
| 355 | func (s *Server) validateOutboundBody(subject, body string, to, cc, bcc []string, conversationID string) *ErrorEnvelope { |
| 356 | if subject == "" || body == "" { |
| 357 | return NewError(http.StatusBadRequest, "invalid_request", "subject and body are required") |
| 358 | } |
| 359 | if strings.ContainsAny(subject, "\r\n") { |
| 360 | return NewError(http.StatusBadRequest, "invalid_request", "subject must not contain CR or LF characters") |
| 361 | } |
| 362 | if len(to) == 0 && len(cc) == 0 { |
| 363 | return NewError(http.StatusBadRequest, "invalid_request", "at least one recipient in to or cc is required") |
| 364 | } |
| 365 | if env := recipientCountError(to, cc, bcc); env != nil { |
| 366 | return env |
| 367 | } |
| 368 | if err := agent.ValidateRecipients(to, cc, bcc); err != nil { |
| 369 | return NewError(http.StatusBadRequest, "invalid_recipient", err.Error()) |
| 370 | } |
| 371 | if err := validateConversationID(conversationID); err != nil { |
| 372 | return NewError(http.StatusBadRequest, "invalid_request", err.Error()) |
| 373 | } |
| 374 | return nil |
| 375 | } |
| 376 | |
| 377 | // deliver runs the domain-verified + enforce-cap checks then DeliverOutbound |
| 378 | // under the idempotency handshake, mapping the OutboundResult to the wire view. |
no test coverage detected