validate_envelope

Function validate_envelope 

Source
pub fn validate_envelope(env: &MessageEnvelope) -> Result<()>
Expand description

Validates an inbound MessageEnvelope for required fields and timestamp correctness.

use gsm_core::{validate_envelope, MessageEnvelope, Platform};
use std::collections::BTreeMap;

let env = MessageEnvelope {
    tenant: "acme".into(),
    platform: Platform::Teams,
    chat_id: "chat-1".into(),
    user_id: "user-7".into(),
    thread_id: None,
    msg_id: "msg-99".into(),
    text: Some("Hello".into()),
    timestamp: "2024-01-01T00:00:00Z".into(),
    context: BTreeMap::new(),
};

validate_envelope(&env).unwrap();