Add reload_user_full and use it to repair action bar.

GitOrigin-RevId: b7b4bc20b944caca0c086d9ecbf99756e8330c61
This commit is contained in:
levlam 2019-10-11 18:39:10 +03:00
parent 9e8512411c
commit d2047ff6d1
3 changed files with 15 additions and 6 deletions

View File

@ -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<Unit> &&promise) {
}
bool ContactsManager::get_user_full(UserId user_id, Promise<Unit> &&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<Unit> &&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<Unit> &&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<telegram_api::InputUser> &&input_user,
Promise<Unit> &&promise, const char *source) {
LOG(INFO) << "Get full " << user_id << " from " << source;

View File

@ -365,6 +365,7 @@ class ContactsManager : public Actor {
bool get_user(UserId user_id, int left_tries, Promise<Unit> &&promise);
void reload_user(UserId user_id, Promise<Unit> &&promise);
bool get_user_full(UserId user_id, Promise<Unit> &&promise);
void reload_user_full(UserId user_id);
std::pair<int32, vector<const Photo *>> get_user_profile_photos(UserId user_id, int32 offset, int32 limit,
Promise<Unit> &&promise);

View File

@ -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: