refactor(tests): reformat code and update dependency management
- 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
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
//! 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user