From d2047ff6d1f3564def7f7d118c6d76dc3dfbdcb2 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 11 Oct 2019 18:39:10 +0300 Subject: [PATCH] Add reload_user_full and use it to repair action bar. GitOrigin-RevId: b7b4bc20b944caca0c086d9ecbf99756e8330c61 --- td/telegram/ContactsManager.cpp | 14 +++++++++++--- td/telegram/ContactsManager.h | 1 + td/telegram/MessagesManager.cpp | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 952ea1e4..163e13e1 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -363,6 +363,7 @@ class SetUserIsBlockedQuery : public Td::ResultHandler { void on_error(uint64 id, Status status) override { if (!G()->close_flag()) { LOG(WARNING) << "Receive error for SetUserIsBlockedQuery: " << status; + td->contacts_manager_->reload_user_full(user_id_); td->messages_manager_->repair_dialog_action_bar(DialogId(user_id_)); } status.ignore(); @@ -9890,8 +9891,8 @@ void ContactsManager::reload_user(UserId user_id, Promise &&promise) { } bool ContactsManager::get_user_full(UserId user_id, Promise &&promise) { - auto user = get_user(user_id); - if (user == nullptr) { + auto u = get_user(user_id); + if (u == nullptr) { promise.set_error(Status::Error(6, "User not found")); return false; } @@ -9907,7 +9908,7 @@ bool ContactsManager::get_user_full(UserId user_id, Promise &&promise) { send_get_user_full_query(user_id, std::move(input_user), std::move(promise), "get_user_full"); return false; } - if (user_full->is_expired() || user_full->is_bot_info_expired(user->bot_info_version)) { + if (user_full->is_expired() || user_full->is_bot_info_expired(u->bot_info_version)) { auto input_user = get_input_user(user_id); CHECK(input_user != nullptr); if (td_->auth_manager_->is_bot()) { @@ -9922,6 +9923,13 @@ bool ContactsManager::get_user_full(UserId user_id, Promise &&promise) { return true; } +void ContactsManager::reload_user_full(UserId user_id) { + auto input_user = get_input_user(user_id); + if (input_user != nullptr) { + send_get_user_full_query(user_id, std::move(input_user), Auto(), "reload_user_full"); + } +} + void ContactsManager::send_get_user_full_query(UserId user_id, tl_object_ptr &&input_user, Promise &&promise, const char *source) { LOG(INFO) << "Get full " << user_id << " from " << source; diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 33a9c8a7..935c8c15 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -365,6 +365,7 @@ class ContactsManager : public Actor { bool get_user(UserId user_id, int left_tries, Promise &&promise); void reload_user(UserId user_id, Promise &&promise); bool get_user_full(UserId user_id, Promise &&promise); + void reload_user_full(UserId user_id); std::pair> get_user_profile_photos(UserId user_id, int32 offset, int32 limit, Promise &&promise); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c8b11f99..873a098c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6442,7 +6442,7 @@ bool MessagesManager::update_dialog_silent_send_message(Dialog *d, bool silent_s void MessagesManager::repair_dialog_action_bar(DialogId dialog_id) { switch (dialog_id.get_type()) { case DialogType::User: - td_->contacts_manager_->get_user_full(dialog_id.get_user_id(), Auto()); + td_->contacts_manager_->reload_user_full(dialog_id.get_user_id()); return; case DialogType::Chat: case DialogType::Channel: @@ -14264,8 +14264,8 @@ void MessagesManager::open_dialog(Dialog *d) { break; case DialogType::SecretChat: // to repair dialog action bar - td_->contacts_manager_->get_user_full( - td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()), Auto()); + td_->contacts_manager_->reload_user_full( + td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id())); break; case DialogType::None: default: