Update dialog online member count when receive member list.
GitOrigin-RevId: e1178f3c5dabc183c80099d0e98e0c0d3cf56762
This commit is contained in:
parent
9aaae62fe3
commit
e406d6ea41
@ -7176,6 +7176,18 @@ void ContactsManager::update_chat_online_member_count(const ChatFull *chat_full,
|
||||
update_dialog_online_member_count(chat_full->participants, DialogId(chat_id), is_from_server);
|
||||
}
|
||||
|
||||
void ContactsManager::update_channel_online_member_count(ChannelId channel_id, bool is_from_server) {
|
||||
if (get_channel_type(channel_id) != ChannelType::Megagroup) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = cached_channel_participants_.find(channel_id);
|
||||
if (it == cached_channel_participants_.end()) {
|
||||
return;
|
||||
}
|
||||
update_dialog_online_member_count(it->second, DialogId(channel_id), is_from_server);
|
||||
}
|
||||
|
||||
void ContactsManager::update_dialog_online_member_count(const vector<DialogParticipant> &participants,
|
||||
DialogId dialog_id, bool is_from_server) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
@ -7458,7 +7470,6 @@ void ContactsManager::on_get_channel_participants_success(
|
||||
int32 administrator_count = filter.is_administrators() ? total_count : -1;
|
||||
if (offset == 0 && static_cast<int32>(participants.size()) < limit &&
|
||||
(filter.is_administrators() || filter.is_bots() || filter.is_recent())) {
|
||||
vector<UserId> participant_user_ids;
|
||||
vector<UserId> administrator_user_ids;
|
||||
vector<UserId> bot_user_ids;
|
||||
{
|
||||
@ -7472,13 +7483,15 @@ void ContactsManager::on_get_channel_participants_success(
|
||||
bot_user_ids.push_back(participant.user_id);
|
||||
}
|
||||
}
|
||||
participant_user_ids = std::move(user_ids);
|
||||
administrator_count = administrator_user_ids.size();
|
||||
} else if (filter.is_administrators()) {
|
||||
administrator_user_ids = std::move(user_ids);
|
||||
} else if (filter.is_bots()) {
|
||||
bot_user_ids = std::move(user_ids);
|
||||
}
|
||||
|
||||
cached_channel_participants_[channel_id] = result;
|
||||
update_channel_online_member_count(channel_id, true);
|
||||
}
|
||||
if (filter.is_administrators() || filter.is_recent()) {
|
||||
on_update_dialog_administrators(DialogId(channel_id), std::move(administrator_user_ids), true);
|
||||
|
@ -172,8 +172,6 @@ class ContactsManager : public Actor {
|
||||
|
||||
void on_update_dialog_administrators(DialogId dialog_id, vector<UserId> administrator_user_ids, bool have_access);
|
||||
|
||||
static bool speculative_add_count(int32 &count, int32 new_count);
|
||||
|
||||
void speculative_add_channel_participants(ChannelId channel_id, int32 new_participant_count, bool by_me);
|
||||
|
||||
void invalidate_channel_full(ChannelId channel_id, bool drop_invite_link);
|
||||
@ -891,6 +889,8 @@ class ContactsManager : public Actor {
|
||||
void on_update_channel_full_invite_link(ChannelFull *channel_full,
|
||||
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link_ptr);
|
||||
|
||||
static bool speculative_add_count(int32 &count, int32 new_count);
|
||||
|
||||
void speculative_add_channel_user(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
||||
DialogParticipantStatus old_status);
|
||||
|
||||
@ -898,6 +898,7 @@ class ContactsManager : public Actor {
|
||||
|
||||
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);
|
||||
void update_dialog_online_member_count(const vector<DialogParticipant> &participants, DialogId dialog_id,
|
||||
bool is_from_server);
|
||||
|
||||
@ -1119,6 +1120,8 @@ class ContactsManager : public Actor {
|
||||
std::unordered_map<int64, DialogParticipant> received_channel_participant_;
|
||||
std::unordered_map<int64, std::pair<int32, vector<DialogParticipant>>> received_channel_participants_;
|
||||
|
||||
std::unordered_map<ChannelId, vector<DialogParticipant>, ChannelIdHash> cached_channel_participants_;
|
||||
|
||||
std::unordered_map<int64, std::pair<int32, vector<UserId>>>
|
||||
found_blocked_users_; // random_id -> [total_count, [user_id]...]
|
||||
|
||||
|
Reference in New Issue
Block a user