Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add telegram_search_media command to query media items in Telegram chats

Tonho2d4697698590
diff --git a/src-tauri/src/commands/telegram.rs b/src-tauri/src/commands/telegram.rs
index 8033e07b..b25f88d6 100644
--- a/src-tauri/src/commands/telegram.rs
+++ b/src-tauri/src/commands/telegram.rs
@@ -549,6 +549,30 @@ pub async fn telegram_get_thumbnail(
Ok(base64::engine::general_purpose::STANDARD.encode(&data))
}
+#[tauri::command]
+pub async fn telegram_search_media(
+ app: tauri::AppHandle,
+ state: tauri::State<'_, AppState>,
+ chat_id: i64,
+ chat_type: String,
+ query: String,
+ media_type: Option<String>,
+ limit: u32,
+) -> Result<Vec<TelegramMediaItem>, String> {
+ let fix_extensions = config::load_settings(&app).telegram.fix_file_extensions;
+ api::search_media(
+ &state.telegram_session,
+ chat_id,
+ &chat_type,
+ &query,
+ media_type.as_deref(),
+ limit,
+ fix_extensions,
+ )
+ .await
+ .map_err(|e| e.to_string())
+}
+
#[tauri::command]
pub async fn telegram_clear_thumbnail_cache() -> Result<(), String> {
thumbnail_cache::clear_cache().await;