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
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
//! 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<Utc>,
|
|
}
|
|
|
|
#[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());
|
|
}
|
|
}
|