//! Sticker attachment on a message — maps to `message_sticker` table. //! //! Large sticker images sent in messages, distinct from emoji reactions. //! Stickers are either workspace-level (custom, defined in appks) or //! system-level (built-in sticker packs). use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use uuid::Uuid; /// A sticker attached to a message. /// /// Maps to the `message_sticker` table. Stickers are larger than emoji /// and can be workspace-level (custom) or system-level (built-in packs). #[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] pub struct MessageSticker { pub id: Uuid, pub message_id: Uuid, /// References a sticker defined in appks (workspace or system sticker). pub sticker_id: Uuid, /// Sticker name at time of send (snapshot for history). pub name: String, /// Image URL (snapshot). pub image_url: String, /// "png" | "apng" | "lottie" pub format_type: String, /// Pack name (e.g. "Wumpus" or workspace name). pub pack_name: Option, /// Search tags for discovery. pub tags: Option, pub created_at: DateTime, } #[cfg(test)] mod tests { use super::*; #[test] fn test_sticker_serialize() { let s = MessageSticker { id: Uuid::now_v7(), message_id: Uuid::now_v7(), sticker_id: Uuid::now_v7(), name: "Hype!".into(), image_url: "https://cdn.example.com/stickers/hype.png".into(), format_type: "png".into(), pack_name: Some("Wumpus".into()), tags: Some("excited,hype".into()), created_at: Utc::now(), }; let json = serde_json::to_value(&s).unwrap(); assert_eq!(json["name"], "Hype!"); assert_eq!(json["format_type"], "png"); } }