Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat: implement Telegram command functions for session management and chat listing
Tonhoa779d90d700d
diff --git a/src-tauri/src/commands/telegram.rs b/src-tauri/src/commands/telegram.rsnew file mode 100644index 00000000..a315d70e--- /dev/null+++ b/src-tauri/src/commands/telegram.rs@@ -0,0 +1,66 @@+use crate::platforms::telegram::api::{self, TelegramChat};+use crate::platforms::telegram::auth::{self, VerifyError};+use crate::AppState;++#[tauri::command]+pub async fn telegram_check_session(+ state: tauri::State<'_, AppState>,+) -> Result<String, String> {+ auth::check_session(&state.telegram_session)+ .await+ .map_err(|e| e.to_string())+}++#[tauri::command]+pub async fn telegram_send_code(+ state: tauri::State<'_, AppState>,+ phone: String,+) -> Result<(), String> {+ auth::send_code(&state.telegram_session, &phone)+ .await+ .map_err(|e| e.to_string())+}++#[tauri::command]+pub async fn telegram_verify_code(+ state: tauri::State<'_, AppState>,+ code: String,+) -> Result<String, String> {+ match auth::verify_code(&state.telegram_session, &code).await {+ Ok(phone) => Ok(phone),+ Err(VerifyError::InvalidCode) => Err("invalid_code".to_string()),+ Err(VerifyError::PasswordRequired { hint }) => {+ Err(format!("password_required:{}", hint))+ }+ Err(VerifyError::NoSession) => Err("no_session".to_string()),+ Err(VerifyError::Other(msg)) => Err(msg),+ }+}++#[tauri::command]+pub async fn telegram_verify_2fa(+ state: tauri::State<'_, AppState>,+ password: String,+) -> Result<String, String> {+ auth::verify_password(&state.telegram_session, &password)+ .await+ .map_err(|e| e.to_string())+}++#[tauri::command]+pub async fn telegram_logout(+ state: tauri::State<'_, AppState>,+) -> Result<(), String> {+ auth::logout(&state.telegram_session)+ .await+ .map_err(|e| e.to_string())+}++#[tauri::command]+pub async fn telegram_list_chats(+ state: tauri::State<'_, AppState>,+) -> Result<Vec<TelegramChat>, String> {+ api::list_chats(&state.telegram_session)+ .await+ .map_err(|e| e.to_string())+}