diff --git a/Cargo.lock b/Cargo.lock index 5a15bb2e..f602c686 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -505,6 +505,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + [[package]] name = "block2" version = "0.6.2" @@ -672,6 +681,15 @@ dependencies = [ "rustversion", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.2.56" @@ -2885,6 +2903,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ + "block-padding", "generic-array", ] @@ -3834,9 +3853,11 @@ dependencies = [ name = "openfang-channels" version = "0.4.4" dependencies = [ + "aes", "async-trait", "axum", "base64 0.22.1", + "cbc", "chrono", "dashmap", "futures", @@ -3848,6 +3869,7 @@ dependencies = [ "mailparse", "native-tls", "openfang-types", + "regex-lite", "reqwest 0.12.28", "serde", "serde_json", diff --git a/crates/openfang-channels/Cargo.toml b/crates/openfang-channels/Cargo.toml index 49e57250..71e10d1e 100644 --- a/crates/openfang-channels/Cargo.toml +++ b/crates/openfang-channels/Cargo.toml @@ -27,6 +27,9 @@ sha2 = { workspace = true } base64 = { workspace = true } hex = { workspace = true } html-escape = { workspace = true } +aes = "0.8" +cbc = "0.1" +regex-lite = "0.1" lettre = { workspace = true } imap = { workspace = true } diff --git a/crates/openfang-channels/src/dingtalk_stream.rs b/crates/openfang-channels/src/dingtalk_stream.rs index c8abf114..d5c96b88 100644 --- a/crates/openfang-channels/src/dingtalk_stream.rs +++ b/crates/openfang-channels/src/dingtalk_stream.rs @@ -99,7 +99,7 @@ impl DingTalkStreamAdapter { ) -> Result<(), Box> { let token = self.get_token().await.map_err(|e| -> Box { e })?; - let (msg_key, msg_param) = match &content { + let (msg_key, _msg_param) = match &content { ChannelContent::Text(t) => ( "sampleText", serde_json::json!({ "content": t }).to_string(), @@ -283,20 +283,12 @@ impl ChannelAdapter for DingTalkStreamAdapter { // ─── Token helpers ─────────────────────────────────────────────────────────── +#[derive(Default)] struct TokenCache { token: String, expire_at: u64, } -impl Default for TokenCache { - fn default() -> Self { - Self { - token: String::new(), - expire_at: 0, - } - } -} - async fn get_access_token( http: &reqwest::Client, app_key: &str,