diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 60ec842e7..62d8649ed 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -9622,6 +9622,10 @@ void ContactsManager::on_load_channel_full_from_database(ChannelId channel_id, s } } + if (invalidated_channels_full_.erase(channel_id) > 0) { + do_invalidate_channel_full(channel_full, !c->is_slow_mode_enabled); + } + td_->group_call_manager_->on_update_dialog_about(DialogId(channel_id), channel_full->description, false); send_closure_later(G()->messages_manager(), &MessagesManager::on_dialog_bots_updated, DialogId(channel_id), @@ -10451,6 +10455,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr &&c return promise.set_value(Unit()); } + invalidated_channels_full_.erase(channel_id); + if (!G()->close_flag()) { auto channel_full = get_channel_full(channel_id, "on_get_channel_full"); if (channel_full != nullptr) { @@ -12035,17 +12041,26 @@ void ContactsManager::drop_channel_photos(ChannelId channel_id, bool is_empty, b void ContactsManager::invalidate_channel_full(ChannelId channel_id, bool need_drop_slow_mode_delay) { LOG(INFO) << "Invalidate supergroup full for " << channel_id; - // drop channel full cache - auto channel_full = get_channel_full_force(channel_id, "invalidate_channel_full"); + auto channel_full = get_channel_full(channel_id, "invalidate_channel_full"); // must not load ChannelFull if (channel_full != nullptr) { - channel_full->expires_at = 0.0; - if (need_drop_slow_mode_delay && channel_full->slow_mode_delay != 0) { - channel_full->slow_mode_delay = 0; - channel_full->slow_mode_next_send_date = 0; - channel_full->is_slow_mode_next_send_date_changed = true; - channel_full->is_changed = true; - } + do_invalidate_channel_full(channel_full, need_drop_slow_mode_delay); update_channel_full(channel_full, channel_id); + } else { + invalidated_channels_full_.insert(channel_id); + } +} + +void ContactsManager::do_invalidate_channel_full(ChannelFull *channel_full, bool need_drop_slow_mode_delay) { + CHECK(channel_full != nullptr); + if (channel_full->expires_at >= Time::now()) { + channel_full->expires_at = 0.0; + channel_full->need_save_to_database = true; + } + if (need_drop_slow_mode_delay && channel_full->slow_mode_delay != 0) { + channel_full->slow_mode_delay = 0; + channel_full->slow_mode_next_send_date = 0; + channel_full->is_slow_mode_next_send_date_changed = true; + channel_full->is_changed = true; } } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 29dce536e..1fcf94df7 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -1264,6 +1264,8 @@ class ContactsManager : public Actor { void drop_channel_photos(ChannelId channel_id, bool is_empty, bool drop_channel_full_photo, const char *source); + void do_invalidate_channel_full(ChannelFull *channel_full, bool need_drop_slow_mode_delay); + void update_user_online_member_count(User *u); void update_chat_online_member_count(const ChatFull *chat_full, ChatId chat_id, bool is_from_server); void update_channel_online_member_count(ChannelId channel_id, bool is_from_server); @@ -1589,6 +1591,7 @@ class ContactsManager : public Actor { std::unordered_map, ChannelIdHash> channels_; std::unordered_map, ChannelIdHash> channels_full_; mutable std::unordered_set unknown_channels_; + std::unordered_set invalidated_channels_full_; std::unordered_map channel_full_file_source_ids_; std::unordered_map, SecretChatIdHash> secret_chats_;