From 4a5b2ac7228786381f95c754b3efe5cd4e9bf47f Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 4 Jan 2023 13:18:38 +0300 Subject: [PATCH] Skip returned by server messages, not matching the filter. --- td/telegram/MessagesManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index b657190ad..a46e63bc2 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -10408,6 +10408,17 @@ void MessagesManager::on_get_dialog_messages_search_result( continue; } + if (filter != MessageSearchFilter::Empty) { + const Message *m = get_message(new_full_message_id); + CHECK(m != nullptr); + auto index_mask = get_message_index_mask(new_full_message_id.get_dialog_id(), m); + if ((message_search_filter_index_mask(filter) & index_mask) == 0) { + LOG(INFO) << "Skip " << new_full_message_id << " of unexpected type"; + total_count--; + continue; + } + } + // TODO check that messages are returned in decreasing message_id order if (message_id < first_added_message_id || !first_added_message_id.is_valid()) { first_added_message_id = message_id;