From 2348e175d9de798a5cb85c346a1255727e2e7c0c Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 16 Jan 2021 12:30:48 +0300 Subject: [PATCH] Add source to get_chat_full_force. --- td/telegram/ContactsManager.cpp | 34 ++++++++++++++++----------------- td/telegram/ContactsManager.h | 4 ++-- td/telegram/MessagesManager.cpp | 2 +- td/telegram/Td.cpp | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index e095dde17..28dc00e35 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -8622,7 +8622,7 @@ void ContactsManager::on_load_chat_full_from_database(ChatId chat_id, string val update_chat_full(chat_full, chat_id, true); } -ContactsManager::ChatFull *ContactsManager::get_chat_full_force(ChatId chat_id) { +ContactsManager::ChatFull *ContactsManager::get_chat_full_force(ChatId chat_id, const char *source) { if (!have_chat_force(chat_id)) { return nullptr; } @@ -8638,7 +8638,7 @@ ContactsManager::ChatFull *ContactsManager::get_chat_full_force(ChatId chat_id) return nullptr; } - LOG(INFO) << "Trying to load full " << chat_id << " from database"; + LOG(INFO) << "Trying to load full " << chat_id << " from database from " << source; on_load_chat_full_from_database(chat_id, G()->td_db()->get_sqlite_sync_pmc()->get(get_chat_full_database_key(chat_id))); return get_chat_full(chat_id); @@ -10450,7 +10450,7 @@ void ContactsManager::on_get_chat_participants(tl_object_ptrversion + 1 == version) { for (auto &participant : chat_full->participants) { @@ -11671,7 +11671,7 @@ void ContactsManager::on_update_chat_delete_user(ChatId chat_id, UserId user_id, LOG(INFO) << "Receive updateChatParticipantDelete from " << chat_id << " with " << user_id << " and version " << version; - ChatFull *chat_full = get_chat_full_force(chat_id); + ChatFull *chat_full = get_chat_full_force(chat_id, "on_update_chat_delete_user"); if (chat_full == nullptr) { LOG(INFO) << "Ignoring update about members of " << chat_id; return; @@ -11930,7 +11930,7 @@ void ContactsManager::on_update_chat_description(ChatId chat_id, string &&descri return; } - auto chat_full = get_chat_full_force(chat_id); + auto chat_full = get_chat_full_force(chat_id, "on_update_chat_description"); if (chat_full == nullptr) { return; } @@ -12006,7 +12006,7 @@ void ContactsManager::drop_chat_photos(ChatId chat_id, bool is_empty, bool drop_ } void ContactsManager::drop_chat_full(ChatId chat_id) { - ChatFull *chat_full = get_chat_full_force(chat_id); + ChatFull *chat_full = get_chat_full_force(chat_id, "drop_chat_full"); if (chat_full == nullptr) { drop_chat_photos(chat_id, false, false, "drop_chat_full"); @@ -12879,27 +12879,27 @@ bool ContactsManager::is_chat_full_outdated(const ChatFull *chat_full, const Cha return false; } -bool ContactsManager::load_chat_full(ChatId chat_id, bool force, Promise &&promise) { +bool ContactsManager::load_chat_full(ChatId chat_id, bool force, Promise &&promise, const char *source) { auto c = get_chat(chat_id); if (c == nullptr) { promise.set_error(Status::Error(6, "Group not found")); return false; } - auto chat_full = get_chat_full_force(chat_id); + auto chat_full = get_chat_full_force(chat_id, source); if (chat_full == nullptr) { LOG(INFO) << "Full " << chat_id << " not found"; - send_get_chat_full_query(chat_id, std::move(promise), "load_chat_full"); + send_get_chat_full_query(chat_id, std::move(promise), source); return false; } if (is_chat_full_outdated(chat_full, c, chat_id)) { LOG(INFO) << "Have outdated full " << chat_id; if (td_->auth_manager_->is_bot() && !force) { - send_get_chat_full_query(chat_id, std::move(promise), "load expired chat_full"); + send_get_chat_full_query(chat_id, std::move(promise), source); return false; } else { - send_get_chat_full_query(chat_id, Auto(), "load expired chat_full"); + send_get_chat_full_query(chat_id, Auto(), source); } } @@ -13388,7 +13388,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 (!load_chat_full(chat_id, force, std::move(promise))) { + } else if (!load_chat_full(chat_id, force, std::move(promise), "get_chat_participant")) { return DialogParticipant(); } // promise is already set @@ -13413,7 +13413,7 @@ std::pair> ContactsManager::search_chat_partici if (force) { promise.set_value(Unit()); - } else if (!load_chat_full(chat_id, force, std::move(promise))) { + } else if (!load_chat_full(chat_id, force, std::move(promise), "search_chat_participants")) { return {}; } // promise is already set @@ -13743,7 +13743,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: - load_chat_full(dialog_id.get_chat_id(), false, std::move(promise)); + load_chat_full(dialog_id.get_chat_id(), false, std::move(promise), "reload_dialog_administrators"); 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 e364661c8..00e5667c2 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -461,7 +461,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 load_chat_full(ChatId chat_id, bool force, Promise &&promise); + bool load_chat_full(ChatId chat_id, bool force, Promise &&promise, const char *source); FileSourceId get_chat_full_file_source_id(ChatId chat_id); void reload_chat_full(ChatId chat_id, Promise &&promise); @@ -1099,7 +1099,7 @@ class ContactsManager : public Actor { const ChatFull *get_chat_full(ChatId chat_id) const; ChatFull *get_chat_full(ChatId chat_id); - ChatFull *get_chat_full_force(ChatId chat_id); + ChatFull *get_chat_full_force(ChatId chat_id, const char *source); ChatFull *add_chat_full(ChatId chat_id); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 93d0e6a40..d943d1a57 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -16265,7 +16265,7 @@ void MessagesManager::get_dialog_info_full(DialogId dialog_id, Promise &&p return; case DialogType::Chat: send_closure_later(G()->contacts_manager(), &ContactsManager::load_chat_full, dialog_id.get_chat_id(), false, - std::move(promise)); + std::move(promise), "get_dialog_info_full"); return; case DialogType::Channel: send_closure_later(G()->contacts_manager(), &ContactsManager::load_channel_full, dialog_id.get_channel_id(), diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 467a1c468..9d582a3d2 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -732,7 +732,7 @@ class GetGroupFullInfoRequest : public RequestActor<> { ChatId chat_id_; void do_run(Promise &&promise) override { - td->contacts_manager_->load_chat_full(chat_id_, get_tries() < 2, std::move(promise)); + td->contacts_manager_->load_chat_full(chat_id_, get_tries() < 2, std::move(promise), "getBasicGroupFullInfo"); } void do_send_result() override {