Move binlog events processing to Td::process_binlog_events.

This commit is contained in:
levlam 2024-01-13 00:42:49 +03:00
parent 0aa8816c28
commit 8b97d2e8e4
2 changed files with 31 additions and 25 deletions

View File

@ -3652,6 +3652,35 @@ void Td::init(Parameters parameters, Result<TdDb::OpenedDatabase> r_opened_datab
option_manager_->on_td_inited();
if (is_online_) {
on_online_updated(true, true);
}
if (auth_manager_->is_bot()) {
set_is_bot_online(true);
}
process_binlog_events(std::move(events));
VLOG(td_init) << "Ping datacenter";
if (!auth_manager_->is_authorized()) {
country_info_manager_->get_current_country_code(Promise<string>());
} else {
updates_manager_->get_difference("init");
schedule_get_terms_of_service(0);
reload_promo_data();
}
complete_pending_preauthentication_requests([](int32 id) { return true; });
VLOG(td_init) << "Finish initialization";
state_ = State::Run;
send_closure(actor_id(this), &Td::send_result, set_parameters_request_id_, td_api::make_object<td_api::ok>());
return finish_set_parameters();
}
void Td::process_binlog_events(TdDb::OpenedDatabase &&events) {
VLOG(td_init) << "Send binlog events";
for (auto &event : events.user_events) {
contacts_manager_->on_binlog_user_event(std::move(event));
@ -3678,13 +3707,6 @@ void Td::init(Parameters parameters, Result<TdDb::OpenedDatabase> r_opened_datab
on_save_app_log_binlog_event(this, std::move(event));
}
if (is_online_) {
on_online_updated(true, true);
}
if (auth_manager_->is_bot()) {
set_is_bot_online(true);
}
// Send binlog events to managers
//
// 1. Actors must receive all binlog events before other queries.
@ -3722,24 +3744,6 @@ void Td::init(Parameters parameters, Result<TdDb::OpenedDatabase> r_opened_datab
std::move(events.to_notification_settings_manager));
send_closure(secret_chats_manager_, &SecretChatsManager::binlog_replay_finish);
VLOG(td_init) << "Ping datacenter";
if (!auth_manager_->is_authorized()) {
country_info_manager_->get_current_country_code(Promise<string>());
} else {
updates_manager_->get_difference("init");
schedule_get_terms_of_service(0);
reload_promo_data();
}
complete_pending_preauthentication_requests([](int32 id) { return true; });
VLOG(td_init) << "Finish initialization";
state_ = State::Run;
send_closure(actor_id(this), &Td::send_result, set_parameters_request_id_, td_api::make_object<td_api::ok>());
return finish_set_parameters();
}
void Td::init_options_and_network() {

View File

@ -1835,6 +1835,8 @@ class Td final : public Actor {
void init_managers();
void process_binlog_events(TdDb::OpenedDatabase &&events);
void clear();
void close_impl(bool destroy_flag);