821537186e
- Reorganized import statements in adapter tests for better readability - Replaced or_insert_with(Vec::new) with or_default() in test closures - Updated Cargo.lock with new dependency versions and checksums - Added TLS features to tonic dependency configuration - Included sqlx, chrono, and uuid dependencies with specific features - Added jsonwebtoken and arc-swap as project dependencies - Reformatted assertion statements to comply with line length limits - Adjusted base64 import order in engine codec module - Updated protobuf include statement formatting
57 lines
1.8 KiB
Rust
57 lines
1.8 KiB
Rust
//! 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<String>,
|
|
/// Search tags for discovery.
|
|
pub tags: Option<String>,
|
|
pub created_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[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");
|
|
}
|
|
}
|