Option "chat_unload_delay" for bots (#1219)

* Option "chat_unload_delay"

This option allows to override the default chat unload delay. The allowed range is from 60 to 86400 seconds (1 day)
This commit is contained in:
Andrea Cavalli 2020-10-02 11:19:43 +02:00 committed by GitHub
parent 771ace5c8d
commit e0b335bc3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -10219,7 +10219,15 @@ 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
return td_->auth_manager_->is_bot() ? DIALOG_UNLOAD_BOT_DELAY : DIALOG_UNLOAD_DELAY;
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;
}
}
void MessagesManager::unload_dialog(DialogId dialog_id) {

View File

@ -7124,6 +7124,9 @@ 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;
}