Move get_service_notifications_user_id to ContactsManager.

GitOrigin-RevId: 451a8db7311a9272d4c6c34653c2a4a82f0cb266
This commit is contained in:
levlam 2018-03-27 00:21:53 +03:00
parent 4e22261c6b
commit 2479353230
3 changed files with 24 additions and 17 deletions

View File

@ -3106,6 +3106,26 @@ 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<telegram_api::user>(
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<telegram_api::userProfilePhoto>(
3337190045231018,
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26779, 5859320227133863146),
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26781, -3695031185685824216)),
nullptr, 0, string(), string(), string());
on_get_user(std::move(user));
}
return user_id;
}
void ContactsManager::check_dialog_username(DialogId dialog_id, const string &username,
Promise<CheckDialogUsernameResult> &&promise) {
if (dialog_id != DialogId() && !dialog_id.is_valid()) {

View File

@ -210,8 +210,11 @@ class ContactsManager : public Actor {
void on_get_channel_full_fail(ChannelId channel_id, Status &&error);
UserId get_my_id(const char *source) const;
void set_my_online_status(bool is_online, bool send_update, bool is_local);
UserId get_service_notifications_user_id();
void on_update_online_status_privacy();
void on_channel_unban_timeout(ChannelId channel_id);

View File

@ -5259,23 +5259,7 @@ void MessagesManager::add_pending_update(tl_object_ptr<telegram_api::Update> &&u
}
MessagesManager::Dialog *MessagesManager::get_service_notifications_dialog() {
UserId service_notifications_user_id(777000);
if (!td_->contacts_manager_->have_user_force(service_notifications_user_id) ||
!td_->contacts_manager_->have_user(service_notifications_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<telegram_api::user>(
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<telegram_api::userProfilePhoto>(
3337190045231018,
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26779, 5859320227133863146),
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26781, -3695031185685824216)),
nullptr, 0, string(), string(), string());
td_->contacts_manager_->on_get_user(std::move(user));
}
UserId service_notifications_user_id = td_->contacts_manager_->get_service_notifications_user_id();
DialogId service_notifications_dialog_id(service_notifications_user_id);
force_create_dialog(service_notifications_dialog_id, "get_service_notifications_dialog");
return get_dialog(service_notifications_dialog_id);