From e8e546a72136eb9b6a0b141d696086618d73553d Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 30 Mar 2020 22:20:34 +0300 Subject: [PATCH] Fix retries in getBasicGroupFullInfo. GitOrigin-RevId: acd566f171998c130f0e3a0544b11e6430148f07 --- td/telegram/ContactsManager.cpp | 10 +++++----- td/telegram/ContactsManager.h | 2 +- td/telegram/MessagesManager.cpp | 2 +- td/telegram/Td.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index d5383dfe0..91b60201d 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -11664,7 +11664,7 @@ bool ContactsManager::is_chat_full_outdated(const ChatFull *chat_full, const Cha return false; } -bool ContactsManager::get_chat_full(ChatId chat_id, Promise &&promise) { +bool ContactsManager::get_chat_full(ChatId chat_id, bool force, Promise &&promise) { auto c = get_chat(chat_id); if (c == nullptr) { promise.set_error(Status::Error(6, "Group not found")); @@ -11680,7 +11680,7 @@ bool ContactsManager::get_chat_full(ChatId chat_id, Promise &&promise) { if (is_chat_full_outdated(chat_full, c, chat_id)) { LOG(INFO) << "Have outdated full " << chat_id; - if (td_->auth_manager_->is_bot()) { + if (td_->auth_manager_->is_bot() && !force) { send_get_chat_full_query(chat_id, std::move(promise), "get expired chat_full"); return false; } else { @@ -12149,7 +12149,7 @@ DialogParticipant ContactsManager::get_chat_participant(ChatId chat_id, UserId u LOG(INFO) << "Trying to get " << user_id << " as member of " << chat_id; if (force) { promise.set_value(Unit()); - } else if (!get_chat_full(chat_id, std::move(promise))) { + } else if (!get_chat_full(chat_id, force, std::move(promise))) { return DialogParticipant(); } // promise is already set @@ -12174,7 +12174,7 @@ std::pair> ContactsManager::search_chat_partici if (force) { promise.set_value(Unit()); - } else if (!get_chat_full(chat_id, std::move(promise))) { + } else if (!get_chat_full(chat_id, force, std::move(promise))) { return {}; } // promise is already set @@ -12492,7 +12492,7 @@ void ContactsManager::on_update_dialog_administrators(DialogId dialog_id, vector void ContactsManager::reload_dialog_administrators(DialogId dialog_id, int32 hash, Promise &&promise) { switch (dialog_id.get_type()) { case DialogType::Chat: - get_chat_full(dialog_id.get_chat_id(), std::move(promise)); + get_chat_full(dialog_id.get_chat_id(), false, std::move(promise)); break; case DialogType::Channel: td_->create_handler(std::move(promise))->send(dialog_id.get_channel_id(), hash); diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 3864182d4..07d42ca51 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -434,7 +434,7 @@ class ContactsManager : public Actor { bool have_chat_force(ChatId chat_id); bool get_chat(ChatId chat_id, int left_tries, Promise &&promise); void reload_chat(ChatId chat_id, Promise &&promise); - bool get_chat_full(ChatId chat_id, Promise &&promise); + bool get_chat_full(ChatId chat_id, bool force, Promise &&promise); bool get_chat_is_active(ChatId chat_id) const; DialogParticipantStatus get_chat_status(ChatId chat_id) const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 55649ad14..15cc329fa 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -13769,7 +13769,7 @@ void MessagesManager::get_dialog_info_full(DialogId dialog_id, Promise &&p td_->contacts_manager_->get_user_full(dialog_id.get_user_id(), std::move(promise)); return; case DialogType::Chat: - td_->contacts_manager_->get_chat_full(dialog_id.get_chat_id(), std::move(promise)); + td_->contacts_manager_->get_chat_full(dialog_id.get_chat_id(), true, std::move(promise)); return; case DialogType::Channel: td_->contacts_manager_->get_channel_full(dialog_id.get_channel_id(), std::move(promise)); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 50810e8c4..81a801557 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -711,7 +711,7 @@ class GetGroupFullInfoRequest : public RequestActor<> { ChatId chat_id_; void do_run(Promise &&promise) override { - td->contacts_manager_->get_chat_full(chat_id_, std::move(promise)); + td->contacts_manager_->get_chat_full(chat_id_, get_tries() < 2, std::move(promise)); } void do_send_result() override {