features: supports WeChat channel

This commit is contained in:
xintaofei
2026-04-02 00:17:23 +08:00
parent a34d14bf59
commit 8050e30a55
25 changed files with 1223 additions and 65 deletions

View File

@@ -6,6 +6,7 @@ use serde::Deserialize;
use crate::app_error::AppCommandError;
use crate::app_state::AppState;
use crate::commands::chat_channel as cc_commands;
use crate::chat_channel::backends::weixin::{WeixinQrcodeInfo, WeixinQrcodeStatus};
use crate::models::chat_channel::{ChannelStatusInfo, ChatChannelInfo, ChatChannelMessageLogInfo};
// ---------------------------------------------------------------------------
@@ -247,3 +248,29 @@ pub async fn set_chat_message_language(
cc_commands::set_chat_message_language_core(&state.db, params.language).await?;
Ok(Json(()))
}
// ---------------------------------------------------------------------------
// WeChat QR code auth
// ---------------------------------------------------------------------------
pub async fn weixin_get_qrcode() -> Result<Json<WeixinQrcodeInfo>, AppCommandError> {
let result = cc_commands::weixin_get_qrcode_core().await?;
Ok(Json(result))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WeixinCheckQrcodeParams {
pub channel_id: i32,
pub qrcode: String,
}
pub async fn weixin_check_qrcode(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<WeixinCheckQrcodeParams>,
) -> Result<Json<WeixinQrcodeStatus>, AppCommandError> {
let result =
cc_commands::weixin_check_qrcode_core(&state.db, params.channel_id, &params.qrcode)
.await?;
Ok(Json(result))
}

View File

@@ -200,6 +200,8 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
.route("/set_chat_event_filter", post(handlers::chat_channel::set_chat_event_filter))
.route("/get_chat_message_language", post(handlers::chat_channel::get_chat_message_language))
.route("/set_chat_message_language", post(handlers::chat_channel::set_chat_message_language))
.route("/weixin_get_qrcode", post(handlers::chat_channel::weixin_get_qrcode))
.route("/weixin_check_qrcode", post(handlers::chat_channel::weixin_check_qrcode))
// ─── Terminal ───
.route("/terminal_spawn", post(handlers::terminal::terminal_spawn))
.route("/terminal_write", post(handlers::terminal::terminal_write))