//! User bookmark on a message — maps to `message_bookmark` table. //! //! Similar to browser bookmarks: user saves a message for later reference, //! optionally with a personal note. use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use uuid::Uuid; /// A user bookmark on a message for later reference. /// /// Maps to the `message_bookmark` table. Similar to browser bookmarks, /// optionally with a personal note. #[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] pub struct MessageBookmark { pub id: Uuid, pub message_id: Uuid, pub channel_id: Uuid, pub user_id: Uuid, /// Personal note the user attached to this bookmark. pub note: Option, pub created_at: DateTime, pub updated_at: DateTime, } #[cfg(test)] mod tests { use super::*; #[test] fn test_bookmark_serialize() { let bm = MessageBookmark { id: Uuid::now_v7(), message_id: Uuid::now_v7(), channel_id: Uuid::now_v7(), user_id: Uuid::now_v7(), note: Some("Important reference".into()), created_at: Utc::now(), updated_at: Utc::now(), }; let json = serde_json::to_value(&bm).unwrap(); assert_eq!(json["note"], "Important reference"); assert!(json["message_id"].is_string()); } }