diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index 2eb77155..5d0ef75a 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -22,6 +22,7 @@ #include "td/telegram/PasswordManager.h" #include "td/telegram/Td.h" #include "td/telegram/TdDb.h" +#include "td/telegram/TopDialogManager.h" #include "td/telegram/UniqueId.h" #include "td/telegram/UpdatesManager.h" @@ -562,6 +563,7 @@ void AuthManager::on_authorization(tl_object_ptrshared_config().set_option_integer("session_count", auth->tmp_sessions_); } td->notification_manager_->init(); + send_closure(td->top_dialog_manager_, &TopDialogManager::do_start_up); td->updates_manager_->get_difference("on_authorization"); td->on_online_updated(false, true); td->schedule_get_terms_of_service(0); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c61949e5..c9d0721e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -8998,7 +8998,7 @@ void MessagesManager::init() { channels_notification_settings_.disable_pinned_message_notifications = false; channels_notification_settings_.disable_mention_notifications = false; channels_notification_settings_.is_synchronized = false; - if (!td_->auth_manager_->is_bot()) { + if (td_->auth_manager_->is_authorized() && !td_->auth_manager_->is_bot()) { send_get_scope_notification_settings_query(NotificationSettingsScope::Channel, Promise<>()); } } diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index 16ea8dcd..3ac6c006 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -635,7 +635,7 @@ void PollManager::on_update_poll_timeout(PollId poll_id) { } void PollManager::on_get_poll_results_failed(PollId poll_id) { - if (!get_poll_is_closed(poll_id)) { + if (!get_poll_is_closed(poll_id) && !td_->auth_manager_->is_bot()) { auto timeout = get_polling_timeout(); LOG(INFO) << "Schedule updating of " << poll_id << " in " << timeout; update_poll_timeout_.add_timeout_in(poll_id.get(), timeout); diff --git a/td/telegram/TopDialogManager.cpp b/td/telegram/TopDialogManager.cpp index 6c627b68..682239aa 100644 --- a/td/telegram/TopDialogManager.cpp +++ b/td/telegram/TopDialogManager.cpp @@ -464,7 +464,16 @@ void TopDialogManager::do_save_top_dialogs() { } void TopDialogManager::start_up() { - is_active_ = G()->parameters().use_chat_info_db && !G()->td().get_actor_unsafe()->auth_manager_->is_bot(); + do_start_up(); +} + +void TopDialogManager::do_start_up() { + auto auth_manager = G()->td().get_actor_unsafe()->auth_manager_.get(); + if (auth_manager == nullptr || !auth_manager->is_authorized()) { + return; + } + + is_active_ = G()->parameters().use_chat_info_db && !auth_manager->is_bot(); is_enabled_ = !G()->shared_config().get_option_boolean("disable_top_chats"); update_rating_e_decay(); diff --git a/td/telegram/TopDialogManager.h b/td/telegram/TopDialogManager.h index 8838b0af..1117f125 100644 --- a/td/telegram/TopDialogManager.h +++ b/td/telegram/TopDialogManager.h @@ -49,6 +49,8 @@ class TopDialogManager : public NetQueryCallback { explicit TopDialogManager(ActorShared<> parent) : parent_(std::move(parent)) { } + void do_start_up(); + void on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date); void remove_dialog(TopDialogCategory category, DialogId dialog_id, tl_object_ptr input_peer);