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))
}