Replace TopDialogManager.is_active_ with !is_bot().
This commit is contained in:
parent
a6fbed2ad7
commit
861f0edab4
@ -197,7 +197,8 @@ void TopDialogManager::on_toggle_top_peers(bool is_enabled, Result<Unit> &&resul
|
||||
}
|
||||
|
||||
void TopDialogManager::on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date) {
|
||||
if (!is_active_ || !is_enabled_) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
if (!is_enabled_) {
|
||||
return;
|
||||
}
|
||||
auto pos = static_cast<size_t>(category);
|
||||
@ -240,7 +241,8 @@ void TopDialogManager::remove_dialog(TopDialogCategory category, DialogId dialog
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "remove_dialog")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!is_active_ || !is_enabled_) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
if (!is_enabled_) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -293,9 +295,7 @@ int TopDialogManager::is_top_dialog(TopDialogCategory category, size_t limit, Di
|
||||
CHECK(category != TopDialogCategory::Size);
|
||||
CHECK(category != TopDialogCategory::ForwardUsers);
|
||||
CHECK(limit > 0);
|
||||
if (!is_active_) {
|
||||
return -1;
|
||||
}
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
if (!is_enabled_) {
|
||||
return 0;
|
||||
}
|
||||
@ -313,7 +313,7 @@ int TopDialogManager::is_top_dialog(TopDialogCategory category, size_t limit, Di
|
||||
}
|
||||
|
||||
void TopDialogManager::update_rating_e_decay() {
|
||||
if (!is_active_) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
rating_e_decay_ = narrow_cast<int32>(G()->get_option_integer("rating_e_decay", rating_e_decay_));
|
||||
@ -554,7 +554,6 @@ void TopDialogManager::init() {
|
||||
return;
|
||||
}
|
||||
|
||||
is_active_ = !td_->auth_manager_->is_bot();
|
||||
is_enabled_ = !G()->get_option_boolean("disable_top_chats");
|
||||
update_rating_e_decay();
|
||||
|
||||
@ -573,12 +572,12 @@ void TopDialogManager::try_start() {
|
||||
server_sync_state_ = SyncState::None;
|
||||
last_server_sync_ = Timestamp();
|
||||
|
||||
LOG(DEBUG) << "Init is enabled: " << is_enabled_;
|
||||
if (!is_active_) {
|
||||
G()->td_db()->get_binlog_pmc()->erase_by_prefix("top_dialogs");
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(DEBUG) << "Init is enabled: " << is_enabled_;
|
||||
|
||||
auto di_top_dialogs_ts = G()->td_db()->get_binlog_pmc()->get("top_dialogs_ts");
|
||||
if (!di_top_dialogs_ts.empty()) {
|
||||
last_server_sync_ = Timestamp::in(to_integer<uint32>(di_top_dialogs_ts) - Clocks::system());
|
||||
@ -616,15 +615,11 @@ void TopDialogManager::try_start() {
|
||||
|
||||
void TopDialogManager::on_first_sync() {
|
||||
was_first_sync_ = true;
|
||||
if (!G()->close_flag() && td_->auth_manager_->is_bot()) {
|
||||
is_active_ = false;
|
||||
try_start();
|
||||
}
|
||||
loop();
|
||||
}
|
||||
|
||||
void TopDialogManager::loop() {
|
||||
if (!is_active_ || G()->close_flag()) {
|
||||
if (td_->auth_manager_->is_bot() || G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ class TopDialogManager final : public Actor {
|
||||
Td *td_;
|
||||
ActorShared<> parent_;
|
||||
|
||||
bool is_active_ = false;
|
||||
bool is_enabled_ = true;
|
||||
bool is_synchronized_ = false;
|
||||
int32 rating_e_decay_ = 241920;
|
||||
|
Loading…
Reference in New Issue
Block a user