Increase message unload delay for bots.
GitOrigin-RevId: ef1de21396a719670cc67f3f90c56fafa5cb4d9e
This commit is contained in:
parent
8edd3b3811
commit
f8cc501d7a
@ -7845,14 +7845,20 @@ void MessagesManager::delete_all_channel_messages_from_user_on_server(ChannelId
|
||||
->send(channel_id, user_id);
|
||||
}
|
||||
|
||||
int32 MessagesManager::get_unload_dialog_delay() const {
|
||||
constexpr int32 DIALOG_UNLOAD_DELAY = 60; // seconds
|
||||
constexpr int32 DIALOG_UNLOAD_BOT_DELAY = 600; // seconds
|
||||
return td_->auth_manager_->is_bot() ? DIALOG_UNLOAD_BOT_DELAY : DIALOG_UNLOAD_DELAY;
|
||||
}
|
||||
|
||||
void MessagesManager::unload_dialog(DialogId dialog_id) {
|
||||
Dialog *d = get_dialog(dialog_id);
|
||||
CHECK(d != nullptr);
|
||||
|
||||
vector<MessageId> to_unload_message_ids;
|
||||
int32 left_to_unload = 0;
|
||||
find_unloadable_messages(d, G()->unix_time_cached() - DIALOG_UNLOAD_DELAY + 2, d->messages, to_unload_message_ids,
|
||||
left_to_unload);
|
||||
find_unloadable_messages(d, G()->unix_time_cached() - get_unload_dialog_delay() + 2, d->messages,
|
||||
to_unload_message_ids, left_to_unload);
|
||||
|
||||
vector<int64> unloaded_message_ids;
|
||||
for (auto message_id : to_unload_message_ids) {
|
||||
@ -7872,7 +7878,7 @@ void MessagesManager::unload_dialog(DialogId dialog_id) {
|
||||
|
||||
if (left_to_unload > 0) {
|
||||
LOG(DEBUG) << "Need to unload " << left_to_unload << " messages more in " << dialog_id;
|
||||
pending_unload_dialog_timeout_.add_timeout_in(d->dialog_id.get(), DIALOG_UNLOAD_DELAY);
|
||||
pending_unload_dialog_timeout_.add_timeout_in(d->dialog_id.get(), get_unload_dialog_delay());
|
||||
}
|
||||
}
|
||||
|
||||
@ -13002,7 +13008,7 @@ void MessagesManager::close_dialog(Dialog *d) {
|
||||
|
||||
if (is_message_unload_enabled()) {
|
||||
LOG(INFO) << "Schedule unload of " << d->dialog_id;
|
||||
pending_unload_dialog_timeout_.set_timeout_in(d->dialog_id.get(), DIALOG_UNLOAD_DELAY);
|
||||
pending_unload_dialog_timeout_.set_timeout_in(d->dialog_id.get(), get_unload_dialog_delay());
|
||||
}
|
||||
|
||||
switch (d->dialog_id.get_type()) {
|
||||
@ -21757,7 +21763,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
||||
|
||||
if (!d->is_opened && d->messages != nullptr && is_message_unload_enabled()) {
|
||||
LOG(INFO) << "Schedule unload of " << dialog_id;
|
||||
pending_unload_dialog_timeout_.add_timeout_in(dialog_id.get(), DIALOG_UNLOAD_DELAY);
|
||||
pending_unload_dialog_timeout_.add_timeout_in(dialog_id.get(), get_unload_dialog_delay());
|
||||
}
|
||||
|
||||
if (message->ttl > 0 && message->ttl_expires_at != 0) {
|
||||
|
@ -1238,7 +1238,6 @@ class MessagesManager : public Actor {
|
||||
static constexpr int32 MIN_SAVE_DRAFT_DELAY = 1; // seconds
|
||||
static constexpr int32 MIN_READ_HISTORY_DELAY = 3; // seconds
|
||||
static constexpr int32 MAX_SAVE_DIALOG_DELAY = 0; // seconds
|
||||
static constexpr int32 DIALOG_UNLOAD_DELAY = 60; // seconds
|
||||
|
||||
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME = 3 * 86400;
|
||||
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME_SHORT = 900;
|
||||
@ -1396,6 +1395,8 @@ class MessagesManager : public Actor {
|
||||
|
||||
void on_message_deleted(Dialog *d, Message *m);
|
||||
|
||||
int32 get_unload_dialog_delay() const;
|
||||
|
||||
void unload_dialog(DialogId dialog_id);
|
||||
|
||||
void delete_all_dialog_messages(Dialog *d, bool remove_from_dialog_list, bool is_permanent);
|
||||
|
Reference in New Issue
Block a user