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
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
//! Message forward CRUD operations on `MessageRepo`.
|
|
|
|
use uuid::Uuid;
|
|
|
|
use crate::ImksResult;
|
|
use crate::models::message_forward::MessageForward;
|
|
|
|
use super::message_repo::MessageRepo;
|
|
|
|
impl MessageRepo {
|
|
/// Record a forwarded message's provenance.
|
|
pub async fn record_forward(
|
|
&self,
|
|
message_id: Uuid,
|
|
source_message_id: Uuid,
|
|
source_channel_id: Uuid,
|
|
forwarded_by: Uuid,
|
|
) -> ImksResult<MessageForward> {
|
|
sqlx::query_as::<_, MessageForward>(
|
|
r#"
|
|
INSERT INTO message_forward (id, message_id, source_message_id, source_channel_id, forwarded_by)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
RETURNING *
|
|
"#,
|
|
)
|
|
.bind(Uuid::now_v7())
|
|
.bind(message_id)
|
|
.bind(source_message_id)
|
|
.bind(source_channel_id)
|
|
.bind(forwarded_by)
|
|
.fetch_one(self.pool())
|
|
.await
|
|
.map_err(Into::into)
|
|
}
|
|
|
|
/// Get forwarding info for a message.
|
|
pub async fn get_forward_info(&self, message_id: Uuid) -> ImksResult<Option<MessageForward>> {
|
|
sqlx::query_as::<_, MessageForward>("SELECT * FROM message_forward WHERE message_id = $1")
|
|
.bind(message_id)
|
|
.fetch_optional(self.pool())
|
|
.await
|
|
.map_err(Into::into)
|
|
}
|
|
}
|