add find messages
This commit is contained in:
@@ -1165,6 +1165,38 @@ impl TdClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Поиск сообщений в чате по тексту
|
||||
pub async fn search_messages(&mut self, chat_id: i64, query: &str) -> Result<Vec<MessageInfo>, String> {
|
||||
if query.trim().is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let result = functions::search_chat_messages(
|
||||
chat_id,
|
||||
query.to_string(),
|
||||
None, // sender_id
|
||||
0, // from_message_id
|
||||
0, // offset
|
||||
50, // limit
|
||||
None, // filter (no filter = search by text)
|
||||
0, // message_thread_id
|
||||
0, // saved_messages_topic_id
|
||||
self.client_id,
|
||||
)
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(tdlib_rs::enums::FoundChatMessages::FoundChatMessages(found)) => {
|
||||
let mut messages: Vec<MessageInfo> = Vec::new();
|
||||
for m in found.messages {
|
||||
messages.push(self.convert_message(&m, chat_id));
|
||||
}
|
||||
Ok(messages)
|
||||
}
|
||||
Err(e) => Err(format!("Ошибка поиска: {:?}", e)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Загрузка старых сообщений (для скролла вверх)
|
||||
pub async fn load_older_messages(
|
||||
&mut self,
|
||||
|
||||
Reference in New Issue
Block a user