Fix updating chat online member count.

GitOrigin-RevId: 9b528ba5ea6524be13baddecabb692c96067caba
This commit is contained in:
levlam 2019-03-13 17:18:40 +03:00
parent 376fda96d5
commit 706144361d
2 changed files with 8 additions and 8 deletions

View File

@ -7459,7 +7459,6 @@ void ContactsManager::on_get_channel_participants_success(
LOG(INFO) << "Receive " << participants.size() << " members in " << channel_id; LOG(INFO) << "Receive " << participants.size() << " members in " << channel_id;
vector<DialogParticipant> result; vector<DialogParticipant> result;
CHECK(result.empty());
for (auto &participant_ptr : participants) { for (auto &participant_ptr : participants) {
result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr))); result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr)));
if ((filter.is_bots() && !is_user_bot(result.back().user_id)) || if ((filter.is_bots() && !is_user_bot(result.back().user_id)) ||
@ -7499,16 +7498,16 @@ void ContactsManager::on_get_channel_participants_success(
} }
} }
administrator_count = narrow_cast<int32>(administrator_user_ids.size()); administrator_count = narrow_cast<int32>(administrator_user_ids.size());
if (get_channel_type(channel_id) == ChannelType::Megagroup && !td_->auth_manager_->is_bot()) {
cached_channel_participants_[channel_id] = result;
update_channel_online_member_count(channel_id, true);
}
} else if (filter.is_administrators()) { } else if (filter.is_administrators()) {
administrator_user_ids = std::move(user_ids); administrator_user_ids = std::move(user_ids);
} else if (filter.is_bots()) { } else if (filter.is_bots()) {
bot_user_ids = std::move(user_ids); bot_user_ids = std::move(user_ids);
} }
if (get_channel_type(channel_id) == ChannelType::Megagroup && !td_->auth_manager_->is_bot()) {
cached_channel_participants_[channel_id] = result;
update_channel_online_member_count(channel_id, true);
}
} }
if (filter.is_administrators() || filter.is_recent()) { if (filter.is_administrators() || filter.is_recent()) {
on_update_dialog_administrators(DialogId(channel_id), std::move(administrator_user_ids), true); on_update_dialog_administrators(DialogId(channel_id), std::move(administrator_user_ids), true);

View File

@ -8585,8 +8585,9 @@ void MessagesManager::set_dialog_online_member_count(DialogId dialog_id, int32 o
return; return;
} }
LOG(INFO) << "Set online member count to " << online_member_count << " in " << dialog_id << " from " << source;
auto &info = dialog_online_member_counts_[dialog_id]; auto &info = dialog_online_member_counts_[dialog_id];
LOG(INFO) << "Change online member count from " << info.online_member_count << " to " << online_member_count << " in "
<< dialog_id << " from " << source;
bool need_update = d->is_opened && (!info.is_update_sent || info.online_member_count != online_member_count); bool need_update = d->is_opened && (!info.is_update_sent || info.online_member_count != online_member_count);
info.online_member_count = online_member_count; info.online_member_count = online_member_count;
info.updated_time = Time::now(); info.updated_time = Time::now();
@ -12981,7 +12982,7 @@ void MessagesManager::open_dialog(Dialog *d) {
case DialogType::Channel: case DialogType::Channel:
if (!is_broadcast_channel(dialog_id)) { if (!is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id()); auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
if (1 <= participant_count && participant_count < 195) { if (participant_count < 195) { // include unknown participant_count
td_->contacts_manager_->send_get_channel_participants_query( td_->contacts_manager_->send_get_channel_participants_query(
dialog_id.get_channel_id(), dialog_id.get_channel_id(),
ChannelParticipantsFilter(td_api::make_object<td_api::supergroupMembersFilterRecent>()), 0, 200, 0, ChannelParticipantsFilter(td_api::make_object<td_api::supergroupMembersFilterRecent>()), 0, 200, 0,