Ignore getDifference responses with invalid polls.

This commit is contained in:
levlam 2023-07-24 19:42:09 +03:00
parent 5110a188b2
commit 8893dc808f
3 changed files with 27 additions and 2 deletions

View File

@ -165,6 +165,8 @@ class MessagesManager final : public Actor {
MessagesManager &operator=(MessagesManager &&) = delete;
~MessagesManager() final;
static bool is_invalid_poll_message(const telegram_api::Message *message);
tl_object_ptr<telegram_api::InputPeer> get_input_peer(DialogId dialog_id, AccessRights access_rights) const;
static tl_object_ptr<telegram_api::InputPeer> get_input_peer_force(DialogId dialog_id);
@ -3012,8 +3014,6 @@ class MessagesManager final : public Actor {
void update_list_last_dialog_date(DialogList &list);
static bool is_invalid_poll_message(const telegram_api::Message *message);
static string get_channel_pts_key(DialogId dialog_id);
int32 load_channel_pts(DialogId dialog_id) const;

View File

@ -1888,6 +1888,17 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.difference");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.difference");
if (get_difference_retry_count_ <= 5) {
for (const auto &message : difference->new_messages_) {
if (MessagesManager::is_invalid_poll_message(message.get())) {
get_difference_retry_count_++;
LOG(ERROR) << "Receive invalid poll message in updates.difference after " << get_difference_retry_count_
<< " tries";
return run_get_difference(true, "reget difference");
}
}
}
process_get_difference_updates(std::move(difference->new_messages_),
std::move(difference->new_encrypted_messages_),
std::move(difference->other_updates_));
@ -1913,6 +1924,17 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.differenceSlice");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.differenceSlice");
if (get_difference_retry_count_ <= 5) {
for (const auto &message : difference->new_messages_) {
if (MessagesManager::is_invalid_poll_message(message.get())) {
get_difference_retry_count_++;
LOG(ERROR) << "Receive invalid poll message in updates.differenceSlice after "
<< get_difference_retry_count_ << " tries";
return run_get_difference(true, "reget difference");
}
}
}
process_get_difference_updates(std::move(difference->new_messages_),
std::move(difference->new_encrypted_messages_),
std::move(difference->other_updates_));
@ -1961,6 +1983,8 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
UNREACHABLE();
}
get_difference_retry_count_ = 0;
if (!running_get_difference_) {
after_get_difference();
}

View File

@ -269,6 +269,7 @@ class UpdatesManager final : public Actor {
int32 min_postponed_update_pts_ = 0;
int32 min_postponed_update_qts_ = 0;
double get_difference_start_time_ = 0; // time from which we started to get difference without success
int32 get_difference_retry_count_ = 0;
FlatHashMap<int64, TranscribedAudioHandler> pending_audio_transcriptions_;
MultiTimeout pending_audio_transcription_timeout_{"PendingAudioTranscriptionTimeout"};