refactor(channel): accept SendMessage struct in Channel::send()
Refactor the Channel trait to accept a SendMessage struct instead of separate message and recipient string parameters. This enables passing additional metadata like email subjects. Changes: - Add SendMessage struct with content, recipient, and optional subject - Update Channel::send() signature to accept &SendMessage - Update all 12 channel implementations - Update call sites in channels/mod.rs and gateway/mod.rs Subject field usage: - Email: uses subject for email subject line - DingTalk: uses subject as markdown message title - All others: ignore subject (no native platform support)
This commit is contained in:
parent
b8ed42edbb
commit
dbebd48dfe
14 changed files with 153 additions and 73 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use super::traits::{Channel, ChannelMessage};
|
||||
use super::traits::{Channel, ChannelMessage, SendMessage};
|
||||
use async_trait::async_trait;
|
||||
|
||||
/// Slack channel — polls conversations.history via Web API
|
||||
|
|
@ -51,10 +51,10 @@ impl Channel for SlackChannel {
|
|||
"slack"
|
||||
}
|
||||
|
||||
async fn send(&self, message: &str, channel: &str) -> anyhow::Result<()> {
|
||||
async fn send(&self, message: &SendMessage) -> anyhow::Result<()> {
|
||||
let body = serde_json::json!({
|
||||
"channel": channel,
|
||||
"text": message
|
||||
"channel": message.recipient,
|
||||
"text": message.content
|
||||
});
|
||||
|
||||
let resp = self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue