Fix MessagesManager initialization after authorization.

GitOrigin-RevId: bf9c4068876e778316218997c41392228633ab7d
This commit is contained in:
levlam 2020-06-04 02:02:17 +03:00
parent c9929b9528
commit 36b8ab4d1d
3 changed files with 26 additions and 10 deletions

View File

@ -720,9 +720,7 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
if ((auth->flags_ & telegram_api::auth_authorization::TMP_SESSIONS_MASK) != 0) {
G()->shared_config().set_option_integer("session_count", auth->tmp_sessions_);
}
if (!is_bot()) {
td->messages_manager_->reload_dialog_filters();
}
td->messages_manager_->on_authorization_success();
td->notification_manager_->init();
td->stickers_manager_->init();
send_closure(td->top_dialog_manager_, &TopDialogManager::do_start_up);

View File

@ -10724,6 +10724,14 @@ void MessagesManager::start_up() {
init();
}
void MessagesManager::create_folders() {
dialog_folders_[FolderId::main()].folder_id = FolderId::main();
dialog_folders_[FolderId::archive()].folder_id = FolderId::archive();
add_dialog_list(DialogListId(FolderId::main()));
add_dialog_list(DialogListId(FolderId::archive()));
}
void MessagesManager::init() {
if (is_inited_) {
return;
@ -10735,12 +10743,8 @@ void MessagesManager::init() {
start_time_ = Time::now();
bool is_authorized_user = !td_->auth_manager_->is_bot() && td_->auth_manager_->is_authorized();
if (is_authorized_user) { // ensure that Main and Archive dialog lists are created
dialog_folders_[FolderId::main()].folder_id = FolderId::main();
dialog_folders_[FolderId::archive()].folder_id = FolderId::archive();
add_dialog_list(DialogListId(FolderId::main()));
add_dialog_list(DialogListId(FolderId::archive()));
if (is_authorized_user) {
create_folders(); // ensure that Main and Archive dialog lists are created
}
if (is_authorized_user) {
@ -11143,6 +11147,17 @@ void MessagesManager::init() {
*/
}
void MessagesManager::on_authorization_success() {
CHECK(td_->auth_manager_->is_authorized());
if (td_->auth_manager_->is_bot()) {
return;
}
create_folders();
reload_dialog_filters();
}
void MessagesManager::ttl_db_loop_start(double server_now) {
ttl_db_expires_from_ = 0;
ttl_db_expires_till_ = static_cast<int32>(server_now) + 15 /* 15 seconds */;

View File

@ -738,7 +738,7 @@ class MessagesManager : public Actor {
void get_login_url(DialogId dialog_id, MessageId message_id, int32 button_id, bool allow_write_access,
Promise<td_api::object_ptr<td_api::httpUrl>> &&promise);
void reload_dialog_filters();
void on_authorization_success();
void before_get_difference();
@ -2248,6 +2248,8 @@ class MessagesManager : public Actor {
static void on_reload_dialog_filters_timeout(void *messages_manager_ptr);
void reload_dialog_filters();
void on_get_dialog_filters(Result<vector<tl_object_ptr<telegram_api::dialogFilter>>> r_filters, bool dummy);
bool need_synchronize_dialog_filters() const;
@ -2422,6 +2424,7 @@ class MessagesManager : public Actor {
void loop() override;
void tear_down() override;
void create_folders();
void init();
void ttl_db_loop_start(double server_now);