fix(channels): complete SendMessage migration after rebase

This commit is contained in:
Chummy 2026-02-17 23:25:52 +08:00
parent dbebd48dfe
commit cd0dd13476
7 changed files with 57 additions and 67 deletions

View file

@ -12,7 +12,7 @@ pub struct ChannelMessage {
}
/// Message to send through a channel
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
pub struct SendMessage {
pub content: String,
pub recipient: String,
@ -43,26 +43,6 @@ impl SendMessage {
}
}
impl From<&str> for SendMessage {
fn from(content: &str) -> Self {
Self {
content: content.to_string(),
recipient: String::new(),
subject: None,
}
}
}
impl From<(String, String)> for SendMessage {
fn from(value: (String, String)) -> Self {
Self {
content: value.0,
recipient: value.1,
subject: None,
}
}
}
/// Core channel trait — implement for any messaging platform
#[async_trait]
pub trait Channel: Send + Sync {
@ -152,7 +132,10 @@ mod tests {
assert!(channel.health_check().await);
assert!(channel.start_typing("bob").await.is_ok());
assert!(channel.stop_typing("bob").await.is_ok());
assert!(channel.send(&SendMessage::new("hello", "bob")).await.is_ok());
assert!(channel
.send(&SendMessage::new("hello", "bob"))
.await
.is_ok());
}
#[tokio::test]