diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 238ca62e5..7a4984235 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -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(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(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); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 8d3a1d28f..befd94d47 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -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,