Skip to main content

gsm_core/
outbound.rs

1use crate::{ChannelMessage, TenantCtx};
2use serde::{Deserialize, Serialize};
3
4/// Generic outbound envelope produced by flows/workers before channel-specific translation.
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct OutboundEnvelope {
7    pub tenant: TenantCtx,
8    pub channel_id: String,
9    pub session_id: String,
10    #[serde(default)]
11    pub meta: serde_json::Value,
12    #[serde(default)]
13    pub body: serde_json::Value,
14}
15
16impl OutboundEnvelope {
17    /// Convenience constructor from a ChannelMessage.
18    pub fn for_channel(channel: &ChannelMessage, body: serde_json::Value) -> Self {
19        Self {
20            tenant: channel.tenant.clone(),
21            channel_id: channel.channel_id.clone(),
22            session_id: channel.session_id.clone(),
23            meta: serde_json::Value::Null,
24            body,
25        }
26    }
27}