Improve ContactsManager::get_channel_effective_has_hidden_participants.

This commit is contained in:
levlam 2022-12-20 15:12:36 +03:00
parent 299dc26be6
commit 8bfc68b3f8
3 changed files with 16 additions and 8 deletions

View File

@ -13321,7 +13321,7 @@ void ContactsManager::update_chat_online_member_count(const ChatFull *chat_full,
}
void ContactsManager::update_channel_online_member_count(ChannelId channel_id, bool is_from_server) {
if (!is_megagroup_channel(channel_id) || get_channel_has_hidden_participants(channel_id)) {
if (!is_megagroup_channel(channel_id) || get_channel_effective_has_hidden_participants(channel_id)) {
return;
}
@ -13566,7 +13566,7 @@ void ContactsManager::on_get_channel_participants(
LOG(INFO) << "Receive " << participants.size() << " " << filter << " members in " << channel_id;
bool is_full = offset == 0 && static_cast<int32>(participants.size()) < limit && total_count < limit;
bool has_hidden_participants = get_channel_has_hidden_participants(channel_id);
bool has_hidden_participants = get_channel_effective_has_hidden_participants(channel_id);
bool is_full_recent = is_full && filter.is_recent() && !has_hidden_participants;
auto channel_type = get_channel_type(channel_id);
@ -16357,10 +16357,18 @@ int32 ContactsManager::get_channel_slow_mode_delay(ChannelId channel_id) {
return channel_full->slow_mode_delay;
}
bool ContactsManager::get_channel_has_hidden_participants(ChannelId channel_id) {
bool ContactsManager::get_channel_effective_has_hidden_participants(ChannelId channel_id) {
auto c = get_channel_force(channel_id);
if (c == nullptr) {
return true;
}
if (get_channel_status(c).is_administrator()) {
return false;
}
auto channel_full = get_channel_full_const(channel_id);
if (channel_full == nullptr) {
channel_full = get_channel_full_force(channel_id, true, "get_channel_has_hidden_participants");
channel_full = get_channel_full_force(channel_id, true, "get_channel_effective_has_hidden_participants");
if (channel_full == nullptr) {
return true;
}

View File

@ -608,7 +608,7 @@ class ContactsManager final : public Actor {
bool get_channel_can_be_deleted(ChannelId channel_id) const;
ChannelId get_channel_linked_channel_id(ChannelId channel_id);
int32 get_channel_slow_mode_delay(ChannelId channel_id);
bool get_channel_has_hidden_participants(ChannelId channel_id);
bool get_channel_effective_has_hidden_participants(ChannelId channel_id);
void add_dialog_participant(DialogId dialog_id, UserId user_id, int32 forward_limit, Promise<Unit> &&promise);

View File

@ -13074,7 +13074,7 @@ void MessagesManager::on_update_dialog_online_member_count_timeout(DialogId dial
if (dialog_id.get_type() == DialogType::Channel && !is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
auto has_hidden_participants =
td_->contacts_manager_->get_channel_has_hidden_participants(dialog_id.get_channel_id());
td_->contacts_manager_->get_channel_effective_has_hidden_participants(dialog_id.get_channel_id());
if (participant_count == 0 || participant_count >= 195 || has_hidden_participants) {
td_->create_handler<GetOnlinesQuery>()->send(dialog_id);
} else {
@ -18751,7 +18751,7 @@ Status MessagesManager::can_get_message_viewers(DialogId dialog_id, const Messag
if (is_broadcast_channel(dialog_id)) {
return Status::Error(400, "Can't get message viewers in channel chats");
}
if (td_->contacts_manager_->get_channel_has_hidden_participants(dialog_id.get_channel_id())) {
if (td_->contacts_manager_->get_channel_effective_has_hidden_participants(dialog_id.get_channel_id())) {
return Status::Error(400, "Participant list is hidden in the chat");
}
participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
@ -21613,7 +21613,7 @@ void MessagesManager::open_dialog(Dialog *d) {
if (!is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(channel_id);
auto has_hidden_participants =
td_->contacts_manager_->get_channel_has_hidden_participants(dialog_id.get_channel_id());
td_->contacts_manager_->get_channel_effective_has_hidden_participants(dialog_id.get_channel_id());
if (participant_count < 195 && !has_hidden_participants) { // include unknown participant_count
td_->contacts_manager_->get_channel_participants(
channel_id, td_api::make_object<td_api::supergroupMembersFilterRecent>(), string(), 0, 200, 200, Auto());