From c9a357f80dcd5d623044f57d638f48c5eb9a1e63 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 25 Jan 2024 22:02:11 +0300 Subject: [PATCH] Support gaps with 0 pts_count in UpdatesManager::on_get_pts_update. --- td/telegram/UpdatesManager.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 55ded440b..1ae644bb8 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -2042,13 +2042,13 @@ void UpdatesManager::on_get_pts_update(int32 pts, if (G()->close_flag() || !td_->auth_manager_->is_authorized()) { return; } + LOG(DEBUG) << "Receive update with PTS " << pts << ": " << to_string(difference_ptr); if (get_pts() != pts - 1 || running_get_difference_ || !postponed_pts_updates_.empty() || - pending_pts_updates_.empty() || pending_pts_updates_.begin()->first != pts + 1) { + pending_pts_updates_.empty() || pending_pts_updates_.begin()->first > pts + 1 || + pending_pts_updates_.begin()->first != pts + pending_pts_updates_.begin()->second.pts_count) { return; } - LOG(DEBUG) << "Receive update with PTS " << pts << ": " << to_string(difference_ptr); - switch (difference_ptr->get_id()) { case telegram_api::updates_difference::ID: { auto difference = move_tl_object_as(difference_ptr); @@ -2084,6 +2084,13 @@ void UpdatesManager::on_get_pts_update(int32 pts, update_message_id->random_id_, MessageId(ServerMessageId(update_message_id->id_)), "on_get_pts_update"); continue; } + if (constructor_id == telegram_api::updateDeleteMessages::ID) { + auto *update_delete_messages = static_cast(update.get()); + if (update_delete_messages->pts_count_ != 0 || update_delete_messages->messages_.size() != 1) { + LOG(ERROR) << "Receive in getDifference " << to_string(update); + } + } + update_ptr = &update; update_count++; }