Rename "chat_unload_delay" option and fix its implementation.

GitOrigin-RevId: a81de53455816c959986cd3924674600d0086adc
This commit is contained in:
levlam 2020-10-02 12:42:16 +03:00
parent e0b335bc3e
commit 86e7186bae
2 changed files with 12 additions and 11 deletions

View File

@ -10220,20 +10220,19 @@ int32 MessagesManager::get_unload_dialog_delay() const {
constexpr int32 DIALOG_UNLOAD_DELAY = 60; // seconds
constexpr int32 DIALOG_UNLOAD_BOT_DELAY = 1800; // seconds
auto is_bot = td_->auth_manager_->is_bot();
auto default_unload_delay = is_bot ? DIALOG_UNLOAD_BOT_DELAY : DIALOG_UNLOAD_DELAY;
if (G()->parameters().use_message_db || is_bot) {
return narrow_cast<int32>(G()->shared_config().get_option_integer("chat_unload_delay", default_unload_delay));
} else {
return default_unload_delay;
}
CHECK(is_message_unload_enabled());
auto default_unload_delay = td_->auth_manager_->is_bot() ? DIALOG_UNLOAD_BOT_DELAY : DIALOG_UNLOAD_DELAY;
return narrow_cast<int32>(G()->shared_config().get_option_integer("message_unload_delay", default_unload_delay));
}
void MessagesManager::unload_dialog(DialogId dialog_id) {
if (G()->close_flag()) {
return;
}
if (!is_message_unload_enabled()) {
// just in case
return;
}
Dialog *d = get_dialog(dialog_id);
CHECK(d != nullptr);

View File

@ -7124,9 +7124,6 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
}
break;
case 'd':
if ((parameters_.use_message_db || is_bot) && set_integer_option("chat_unload_delay", 60, 86400)) {
return;
}
if (!is_bot && set_boolean_option("disable_contact_registered_notifications")) {
return;
}
@ -7199,6 +7196,11 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
return;
}
break;
case 'm':
if (set_integer_option("message_unload_delay", 60, 86400)) {
return;
}
break;
case 'n':
if (!is_bot &&
set_integer_option("notification_group_count_max", NotificationManager::MIN_NOTIFICATION_GROUP_COUNT_MAX,