Rename chat_unload_delay and fix its implementation

This commit is contained in:
Andrea Cavalli 2020-10-02 17:32:24 +02:00
parent e8e9dc4abf
commit 011d5c123a
2 changed files with 13 additions and 6 deletions

View File

@ -10238,14 +10238,19 @@ void MessagesManager::delete_all_channel_messages_from_user_on_server(ChannelId
int32 MessagesManager::get_unload_dialog_delay() const {
constexpr int32 DIALOG_UNLOAD_DELAY = 60; // seconds
constexpr int32 DIALOG_UNLOAD_BOT_DELAY = 1800; // seconds
auto default_value = td_->auth_manager_->is_bot() ? DIALOG_UNLOAD_BOT_DELAY : DIALOG_UNLOAD_DELAY;
return narrow_cast<int32>(G()->shared_config().get_option_integer("chat_unload_delay", default_value));
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);
@ -13904,7 +13909,7 @@ void MessagesManager::dump_debug_message_op(const Dialog *d, int priority) {
}
bool MessagesManager::is_message_unload_enabled() const {
auto has_custom_unload_time = G()->shared_config().have_option("chat_unload_delay");
auto has_custom_unload_time = G()->shared_config().have_option("message_unload_delay");
return G()->parameters().use_message_db || td_->auth_manager_->is_bot() || has_custom_unload_time;
}

View File

@ -7142,9 +7142,6 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
}
break;
case 'd':
if (set_integer_option("dialog_unload_delay")) {
return;
}
if (!is_bot && set_boolean_option("disable_contact_registered_notifications")) {
return;
}
@ -7251,6 +7248,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,