MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / validateOutboundBody

Method validateOutboundBody

internal/httpapi/outbound.go:355–375  ·  view source on GitHub ↗

validateOutboundBody runs the shared pre-send validation.

(subject, body string, to, cc, bcc []string, conversationID string)

Source from the content-addressed store, hash-verified

353
354// validateOutboundBody runs the shared pre-send validation.
355func (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.

Callers 1

handleCreateMessageMethod · 0.95

Calls 5

ValidateRecipientsFunction · 0.92
NewErrorFunction · 0.85
recipientCountErrorFunction · 0.85
validateConversationIDFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected