//! Message forwarding trail — maps to `message_forward` table. //! //! When a user forwards a message from one channel to another, this table //! records the provenance. The forwarded message is a new message with a //! copy of the original body, linked back via `source_message_id`. use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use uuid::Uuid; /// A forwarded message linking the copy to the original. /// /// Maps to the `message_forward` table. Records provenance when a user /// forwards a message from one channel to another. #[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] pub struct MessageForward { pub id: Uuid, /// The new (forwarded) message. pub message_id: Uuid, /// The original message being forwarded. pub source_message_id: Uuid, /// The channel the original message came from. pub source_channel_id: Uuid, /// Who forwarded the message. pub forwarded_by: Uuid, pub created_at: DateTime, } #[cfg(test)] mod tests { use super::*; #[test] fn test_forward_serialize() { let f = MessageForward { id: Uuid::now_v7(), message_id: Uuid::now_v7(), source_message_id: Uuid::now_v7(), source_channel_id: Uuid::now_v7(), forwarded_by: Uuid::now_v7(), created_at: Utc::now(), }; let json = serde_json::to_value(&f).unwrap(); assert!(json["source_message_id"].is_string()); assert!(json["source_channel_id"].is_string()); } }