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 crate::channels::traits::{Channel, ChannelMessage};
|
||||
use crate::channels::traits::{Channel, ChannelMessage, SendMessage};
|
||||
use async_trait::async_trait;
|
||||
use reqwest::Client;
|
||||
use serde::Deserialize;
|
||||
|
|
@ -117,7 +117,7 @@ impl Channel for MatrixChannel {
|
|||
"matrix"
|
||||
}
|
||||
|
||||
async fn send(&self, message: &str, _target: &str) -> anyhow::Result<()> {
|
||||
async fn send(&self, message: &SendMessage) -> anyhow::Result<()> {
|
||||
let txn_id = format!("zc_{}", chrono::Utc::now().timestamp_millis());
|
||||
let url = format!(
|
||||
"{}/_matrix/client/v3/rooms/{}/send/m.room.message/{}",
|
||||
|
|
@ -126,7 +126,7 @@ impl Channel for MatrixChannel {
|
|||
|
||||
let body = serde_json::json!({
|
||||
"msgtype": "m.text",
|
||||
"body": message
|
||||
"body": message.content
|
||||
});
|
||||
|
||||
let resp = self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue