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
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
//! 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<String>,
|
|
pub created_at: DateTime<Utc>,
|
|
pub updated_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[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());
|
|
}
|
|
}
|