diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index 64915de36..338148373 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -709,7 +709,7 @@ void AuthManager::on_delete_account_result(NetQueryPtr &result) { auto r_delete_account = fetch_result(result->ok()); if (r_delete_account.is_ok()) { if (!r_delete_account.ok()) { - status = Status::Error(500, "Receive false as result of the request"); + // status = Status::Error(500, "Receive false as result of the request"); } } else { status = r_delete_account.move_as_error(); diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 532000592..7962cbb7e 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -3108,20 +3108,8 @@ void ContactsManager::set_my_online_status(bool is_online, bool send_update, boo UserId ContactsManager::get_service_notifications_user_id() { UserId user_id(777000); - if (!have_user_force(user_id) || !have_user(user_id)) { - int32 flags = telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::FIRST_NAME_MASK | - telegram_api::user::LAST_NAME_MASK | telegram_api::user::PHONE_MASK | telegram_api::user::PHOTO_MASK | - telegram_api::user::VERIFIED_MASK; - auto user = telegram_api::make_object( - flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, 777000, 1, "Telegram", "Updates", string(), "42777", - telegram_api::make_object( - 3337190045231018, - telegram_api::make_object(1, 702229962, 26779, 5859320227133863146), - telegram_api::make_object(1, 702229962, 26781, -3695031185685824216)), - nullptr, 0, string(), string(), string()); - on_get_user(std::move(user)); + if (!have_user_force(user_id)) { + LOG(FATAL) << "Failed to load service notification user"; } return user_id; } @@ -5276,6 +5264,33 @@ bool ContactsManager::have_user_force(UserId user_id) { } ContactsManager::User *ContactsManager::get_user_force(UserId user_id) { + auto u = get_user_force_impl(user_id); + if (user_id == UserId(777000) && (u == nullptr || !u->is_received)) { + int32 flags = telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::FIRST_NAME_MASK | + telegram_api::user::LAST_NAME_MASK | telegram_api::user::PHONE_MASK | telegram_api::user::PHOTO_MASK | + telegram_api::user::VERIFIED_MASK; + auto profile_photo = telegram_api::make_object( + 3337190045231018, + telegram_api::make_object(1, 702229962, 26779, 5859320227133863146), + telegram_api::make_object(1, 702229962, 26781, -3695031185685824216)); + if (G()->is_test_dc()) { + profile_photo = nullptr; + flags -= telegram_api::user::PHOTO_MASK; + } + + auto user = telegram_api::make_object( + flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, 777000, 1, "Telegram", "Updates", string(), "42777", std::move(profile_photo), + nullptr, 0, string(), string(), string()); + on_get_user(std::move(user)); + u = get_user(user_id); + CHECK(u != nullptr && u->is_received); + } + return u; +} + +ContactsManager::User *ContactsManager::get_user_force_impl(UserId user_id) { if (!user_id.is_valid()) { return nullptr; } @@ -7983,6 +7998,10 @@ bool ContactsManager::get_user(UserId user_id, int left_tries, Promise &&p return false; } + if (user_id == UserId(777000)) { + get_user_force(user_id); // preload 777000 synchronously + } + // TODO support loading user from database and merging it with min-user in memory if (!have_min_user(user_id)) { // TODO UserLoader diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 9e6975e28..ccfae6b1f 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -762,6 +762,7 @@ class ContactsManager : public Actor { const User *get_user(UserId user_id) const; User *get_user(UserId user_id); User *get_user_force(UserId user_id); + User *get_user_force_impl(UserId user_id); User *add_user(UserId user_id);