Reload promo data sequentially.
This commit is contained in:
parent
511689877c
commit
a9ba8f5a6c
@ -1044,7 +1044,7 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
||||
td_->on_online_updated(false, true);
|
||||
if (!is_bot()) {
|
||||
td_->schedule_get_terms_of_service(0);
|
||||
td_->schedule_get_promo_data(0);
|
||||
td_->reload_promo_data();
|
||||
G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1");
|
||||
} else {
|
||||
td_->set_is_bot_online(true);
|
||||
|
@ -2555,6 +2555,7 @@ void Td::on_alarm_timeout(int64 alarm_id) {
|
||||
}
|
||||
if (alarm_id == PROMO_DATA_ALARM_ID) {
|
||||
if (!close_flag_ && !auth_manager_->is_bot()) {
|
||||
reloading_promo_data_ = true;
|
||||
auto promise = PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this)](Result<telegram_api::object_ptr<telegram_api::help_PromoData>> result) {
|
||||
send_closure(actor_id, &Td::on_get_promo_data, std::move(result), false);
|
||||
@ -2646,6 +2647,7 @@ void Td::on_get_promo_data(Result<telegram_api::object_ptr<telegram_api::help_Pr
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
reloading_promo_data_ = false;
|
||||
|
||||
if (r_promo_data.is_error()) {
|
||||
LOG(ERROR) << "Receive error for GetPromoData: " << r_promo_data.error();
|
||||
@ -2677,9 +2679,21 @@ void Td::on_get_promo_data(Result<telegram_api::object_ptr<telegram_api::help_Pr
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (need_reload_promo_data_) {
|
||||
need_reload_promo_data_ = false;
|
||||
expires_at = 0;
|
||||
}
|
||||
schedule_get_promo_data(expires_at == 0 ? 0 : expires_at - G()->unix_time());
|
||||
}
|
||||
|
||||
void Td::reload_promo_data() {
|
||||
if (reloading_promo_data_) {
|
||||
need_reload_promo_data_ = true;
|
||||
return;
|
||||
}
|
||||
schedule_get_promo_data(0);
|
||||
}
|
||||
|
||||
void Td::schedule_get_promo_data(int32 expires_in) {
|
||||
expires_in = expires_in <= 0 ? 0 : clamp(expires_in, 60, 86400);
|
||||
if (!close_flag_ && auth_manager_->is_authorized() && !auth_manager_->is_bot()) {
|
||||
@ -3693,7 +3707,7 @@ void Td::init(Parameters parameters, Result<TdDb::OpenedDatabase> r_opened_datab
|
||||
} else {
|
||||
updates_manager_->get_difference("init");
|
||||
schedule_get_terms_of_service(0);
|
||||
schedule_get_promo_data(0);
|
||||
reload_promo_data();
|
||||
}
|
||||
|
||||
complete_pending_preauthentication_requests([](int32 id) { return true; });
|
||||
|
@ -116,7 +116,7 @@ class Td final : public Actor {
|
||||
|
||||
void schedule_get_terms_of_service(int32 expires_in);
|
||||
|
||||
void schedule_get_promo_data(int32 expires_in);
|
||||
void reload_promo_data();
|
||||
|
||||
void on_update(BufferSlice &&update, uint64 auth_key_id);
|
||||
|
||||
@ -313,6 +313,9 @@ class Td final : public Actor {
|
||||
|
||||
bool can_ignore_background_updates_ = false;
|
||||
|
||||
bool reloading_promo_data_ = false;
|
||||
bool need_reload_promo_data_ = false;
|
||||
|
||||
bool is_online_ = false;
|
||||
bool is_bot_online_ = false;
|
||||
NetQueryRef update_status_query_;
|
||||
@ -375,6 +378,8 @@ class Td final : public Actor {
|
||||
|
||||
std::shared_ptr<ActorContext> old_context_;
|
||||
|
||||
void schedule_get_promo_data(int32 expires_in);
|
||||
|
||||
static int *get_log_verbosity_level(Slice name);
|
||||
|
||||
template <class T>
|
||||
|
@ -419,7 +419,7 @@ void ConnectionCreator::enable_proxy_impl(int32 proxy_id) {
|
||||
void ConnectionCreator::disable_proxy_impl() {
|
||||
if (active_proxy_id_ == 0) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::remove_sponsored_dialog);
|
||||
send_closure(G()->td(), &Td::schedule_get_promo_data, 0);
|
||||
send_closure(G()->td(), &Td::reload_promo_data);
|
||||
return;
|
||||
}
|
||||
CHECK(proxies_.count(active_proxy_id_) == 1);
|
||||
@ -454,7 +454,7 @@ void ConnectionCreator::on_proxy_changed(bool from_db) {
|
||||
if (active_proxy_id_ == 0 || !from_db) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::remove_sponsored_dialog);
|
||||
}
|
||||
send_closure(G()->td(), &Td::schedule_get_promo_data, 0);
|
||||
send_closure(G()->td(), &Td::reload_promo_data);
|
||||
|
||||
loop();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user