diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index ba027fe04..7ffbaa485 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6396,8 +6396,8 @@ void MessagesManager::skip_old_pending_pts_update(tl_object_ptr(update.get()); auto full_message_id = get_full_message_id(update_new_message->message_, false); if (update_message_ids_.count(full_message_id) > 0) { - if (new_pts == old_pts) { // otherwise message can be already deleted - // apply sent message anyway + if (new_pts == old_pts || old_pts == std::numeric_limits::max()) { + // apply sent message anyway if it is definitely non-deleted or being skipped because of pts overflow on_get_message(std::move(update_new_message->message_), true, false, false, true, true, "updateNewMessage with an awaited message"); return; @@ -6411,8 +6411,8 @@ void MessagesManager::skip_old_pending_pts_update(tl_object_ptrget_id() == updateSentMessage::ID) { auto update_sent_message = static_cast(update.get()); if (being_sent_messages_.count(update_sent_message->random_id_) > 0) { - if (new_pts == old_pts) { // otherwise message can be already deleted - // apply sent message anyway + if (new_pts == old_pts || old_pts == std::numeric_limits::max()) { + // apply sent message anyway if it is definitely non-deleted or being skipped because of pts overflow on_send_message_success(update_sent_message->random_id_, update_sent_message->message_id_, update_sent_message->date_, update_sent_message->ttl_period_, FileId(), "process old updateSentMessage"); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 63cf0f211..370426168 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1063,7 +1063,10 @@ void UpdatesManager::on_get_updates_state(tl_object_ptrpts_; // restoring right pts CHECK(pending_pts_updates_.empty()); + auto real_running_get_difference = running_get_difference_; + running_get_difference_ = false; process_postponed_pts_updates(); // drop all updates with old pts + running_get_difference_ = real_running_get_difference; pts_manager_.init(state->pts_); last_get_difference_pts_ = get_pts(); last_pts_save_time_ = Time::now() - 2 * MAX_PTS_SAVE_DELAY;