From 1b3d14a3f950f408cdd11632394b8b9b13394ee1 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 17 Jul 2023 18:22:41 +0300 Subject: [PATCH] Add source to reload_user_full and reload_chat_full. --- td/telegram/BotInfoManager.cpp | 2 +- td/telegram/ContactsManager.cpp | 22 +++++++++++----------- td/telegram/ContactsManager.h | 4 ++-- td/telegram/FileReferenceManager.cpp | 6 +++--- td/telegram/MessagesManager.cpp | 15 ++++++++------- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/td/telegram/BotInfoManager.cpp b/td/telegram/BotInfoManager.cpp index cbbb1d41d..741617337 100644 --- a/td/telegram/BotInfoManager.cpp +++ b/td/telegram/BotInfoManager.cpp @@ -161,7 +161,7 @@ class SetBotInfoQuery final : public Td::ResultHandler { if (set_info_) { invalidate_bot_info(); if (!td_->auth_manager_->is_bot()) { - return td_->contacts_manager_->reload_user_full(bot_user_id_, std::move(promise_)); + return td_->contacts_manager_->reload_user_full(bot_user_id_, std::move(promise_), "SetBotInfoQuery"); } } if (set_name_) { diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index c3000987d..fb14d6886 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -7625,7 +7625,7 @@ void ContactsManager::delete_profile_photo(int64 profile_photo_id, bool is_recur } send_closure(actor_id, &ContactsManager::delete_profile_photo, profile_photo_id, true, std::move(promise)); }); - reload_user_full(get_my_id(), std::move(reload_promise)); + reload_user_full(get_my_id(), std::move(reload_promise), "delete_profile_photo"); return; } if (user_full->photo.id.get() == profile_photo_id || user_full->fallback_photo.id.get() == profile_photo_id) { @@ -11607,7 +11607,7 @@ void ContactsManager::on_load_user_full_from_database(UserId user_id, string val if (is_user_deleted(u)) { drop_user_full(user_id); } else if (user_full->expires_at == 0.0) { - reload_user_full(user_id, Auto()); + reload_user_full(user_id, Auto(), "on_load_user_full_from_database"); } } @@ -11705,7 +11705,7 @@ void ContactsManager::on_load_chat_full_from_database(ChatId chat_id, string val if (!is_same_dialog_photo(td_->file_manager_.get(), DialogId(chat_id), chat_full->photo, c->photo, false)) { chat_full->photo = Photo(); if (c->photo.small_file_id.is_valid()) { - reload_chat_full(chat_id, Auto()); + reload_chat_full(chat_id, Auto(), "on_load_chat_full_from_database"); } } @@ -12073,7 +12073,7 @@ void ContactsManager::update_chat(Chat *c, ChatId chat_id, bool from_binlog, boo need_update_chat_full = true; } if (c->photo.small_file_id.is_valid()) { - reload_chat_full(chat_id, Auto()); + reload_chat_full(chat_id, Auto(), "update_chat"); } } } @@ -13988,7 +13988,7 @@ void ContactsManager::add_set_profile_photo_to_cache(UserId user_id, Photo &&pho user_full->need_save_to_database = true; } update_user_full(user_full, user_id, "add_set_profile_photo_to_cache"); - reload_user_full(user_id, Auto()); + reload_user_full(user_id, Auto(), "add_set_profile_photo_to_cache"); } } @@ -14073,7 +14073,7 @@ bool ContactsManager::delete_my_profile_photo_from_cache(int64 profile_photo_id) user_full->expires_at = 0.0; user_full->need_save_to_database = true; } - reload_user_full(user_id, Auto()); + reload_user_full(user_id, Auto(), "delete_my_profile_photo_from_cache"); update_user_full(user_full, user_id, "delete_my_profile_photo_from_cache"); } } @@ -15778,7 +15778,7 @@ void ContactsManager::on_update_chat_photo(Chat *c, ChatId chat_id, DialogPhoto chat_full->is_changed = true; } if (c->photo.small_file_id.is_valid()) { - reload_chat_full(chat_id, Auto()); + reload_chat_full(chat_id, Auto(), "on_update_chat_photo"); } update_chat_full(chat_full, chat_id, "on_update_chat_photo"); } @@ -16706,9 +16706,9 @@ void ContactsManager::load_user_full(UserId user_id, bool force, Promise & promise.set_value(Unit()); } -void ContactsManager::reload_user_full(UserId user_id, Promise &&promise) { +void ContactsManager::reload_user_full(UserId user_id, Promise &&promise, const char *source) { TRY_RESULT_PROMISE(promise, input_user, get_input_user(user_id)); - send_get_user_full_query(user_id, std::move(input_user), std::move(promise), "reload_user_full"); + send_get_user_full_query(user_id, std::move(input_user), std::move(promise), source); } void ContactsManager::send_get_user_full_query(UserId user_id, tl_object_ptr &&input_user, @@ -17095,8 +17095,8 @@ void ContactsManager::load_chat_full(ChatId chat_id, bool force, Promise & promise.set_value(Unit()); } -void ContactsManager::reload_chat_full(ChatId chat_id, Promise &&promise) { - send_get_chat_full_query(chat_id, std::move(promise), "reload_chat_full"); +void ContactsManager::reload_chat_full(ChatId chat_id, Promise &&promise, const char *source) { + send_get_chat_full_query(chat_id, std::move(promise), source); } void ContactsManager::send_get_chat_full_query(ChatId chat_id, Promise &&promise, const char *source) { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 30109c649..1ea776a74 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -594,7 +594,7 @@ class ContactsManager final : public Actor { void reload_user(UserId user_id, Promise &&promise); void load_user_full(UserId user_id, bool force, Promise &&promise, const char *source); FileSourceId get_user_full_file_source_id(UserId user_id); - void reload_user_full(UserId user_id, Promise &&promise); + void reload_user_full(UserId user_id, Promise &&promise, const char *source); void get_user_profile_photos(UserId user_id, int32 offset, int32 limit, Promise> &&promise); @@ -607,7 +607,7 @@ class ContactsManager final : public Actor { void reload_chat(ChatId chat_id, Promise &&promise); void 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); + void reload_chat_full(ChatId chat_id, Promise &&promise, const char *source); int32 get_chat_date(ChatId chat_id) const; int32 get_chat_participant_count(ChatId chat_id) const; diff --git a/td/telegram/FileReferenceManager.cpp b/td/telegram/FileReferenceManager.cpp index c644693b1..9c3a692c1 100644 --- a/td/telegram/FileReferenceManager.cpp +++ b/td/telegram/FileReferenceManager.cpp @@ -353,11 +353,11 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source }, [&](const FileSourceChatFull &source) { send_closure_later(G()->contacts_manager(), &ContactsManager::reload_chat_full, source.chat_id, - std::move(promise)); + std::move(promise), "FileSourceChatFull"); }, [&](const FileSourceChannelFull &source) { send_closure_later(G()->contacts_manager(), &ContactsManager::reload_channel_full, source.channel_id, - std::move(promise), "repair file reference"); + std::move(promise), "FileSourceChannelFull"); }, [&](const FileSourceAppConfig &source) { send_closure_later(G()->config_manager(), &ConfigManager::reget_app_config, std::move(promise)); @@ -368,7 +368,7 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source }, [&](const FileSourceUserFull &source) { send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user_full, source.user_id, - std::move(promise)); + std::move(promise), "FileSourceUserFull"); }, [&](const FileSourceAttachMenuBot &source) { send_closure_later(G()->attach_menu_manager(), &AttachMenuManager::reload_attach_menu_bot, source.user_id, diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8c6e09083..f490ea6e8 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -8675,7 +8675,7 @@ void MessagesManager::reget_dialog_action_bar(DialogId dialog_id, const char *so LOG(INFO) << "Reget action bar in " << dialog_id << " from " << source; switch (dialog_id.get_type()) { case DialogType::User: - td_->contacts_manager_->reload_user_full(dialog_id.get_user_id(), Auto()); + td_->contacts_manager_->reload_user_full(dialog_id.get_user_id(), Auto(), source); return; case DialogType::Chat: case DialogType::Channel: @@ -18228,7 +18228,8 @@ void MessagesManager::on_get_message_viewers(DialogId dialog_id, MessageViewers switch (dialog_id.get_type()) { case DialogType::Chat: - return td_->contacts_manager_->reload_chat_full(dialog_id.get_chat_id(), std::move(query_promise)); + return td_->contacts_manager_->reload_chat_full(dialog_id.get_chat_id(), std::move(query_promise), + "on_get_message_viewers"); case DialogType::Channel: return td_->contacts_manager_->get_channel_participants( dialog_id.get_channel_id(), td_api::make_object(), string(), 0, @@ -18317,11 +18318,11 @@ void MessagesManager::reload_dialog_info_full(DialogId dialog_id, const char *so switch (dialog_id.get_type()) { case DialogType::User: send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_user_full, dialog_id.get_user_id(), - Promise()); + Promise(), source); return; case DialogType::Chat: send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_chat_full, dialog_id.get_chat_id(), - Promise()); + Promise(), source); return; case DialogType::Channel: send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_channel_full, @@ -20524,7 +20525,7 @@ void MessagesManager::open_dialog(Dialog *d) { // to repair dialog action bar auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()); if (user_id.is_valid()) { - td_->contacts_manager_->reload_user_full(user_id, Promise()); + td_->contacts_manager_->reload_user_full(user_id, Promise(), "open_dialog"); } break; } @@ -35067,7 +35068,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq switch (dialog_type) { case DialogType::User: td_->contacts_manager_->invalidate_user_full(dialog_id.get_user_id()); - td_->contacts_manager_->reload_user_full(dialog_id.get_user_id(), Promise()); + td_->contacts_manager_->reload_user_full(dialog_id.get_user_id(), Promise(), "add_message_to_dialog"); break; case DialogType::Chat: case DialogType::Channel: @@ -35077,7 +35078,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()); if (user_id.is_valid()) { td_->contacts_manager_->invalidate_user_full(user_id); - td_->contacts_manager_->reload_user_full(user_id, Promise()); + td_->contacts_manager_->reload_user_full(user_id, Promise(), "add_message_to_dialog"); } break; }