From d3a82b449c942bb7257b2153233fefc7844b4a7e Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 12 Mar 2019 11:58:37 +0300 Subject: [PATCH] Update channel member count when receive member list. GitOrigin-RevId: 6f5b2f90cbf0085b7ff68f80bf0529fbf3dc1bf3 --- td/telegram/ContactsManager.cpp | 14 ++++++++++++++ td/telegram/DialogParticipant.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index f6711822b..16ca953d9 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -7441,6 +7441,20 @@ void ContactsManager::on_get_channel_participants_success( result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr))); } + if (filter.is_recent() && total_count != 0 && total_count < 10000) { + auto channel_full = get_channel_full(channel_id); + if (channel_full != nullptr && channel_full->participant_count != total_count) { + channel_full->participant_count = total_count; + channel_full->is_changed = true; + update_channel_full(channel_full, channel_id); + } + auto c = get_channel(channel_id); + if (c != nullptr && c->participant_count != total_count) { + c->participant_count = total_count; + c->need_send_update = true; + update_channel(c, channel_id); + } + } if (offset == 0 && static_cast(participants.size()) < limit) { if (filter.is_administrators() || filter.is_bots()) { auto user_ids = transform(result, [](const DialogParticipant &participant) { return participant.user_id; }); diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index db4bc4142..c2e188fc4 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -262,6 +262,10 @@ class ChannelParticipantsFilter { bool is_bots() const { return type == Type::Bots; } + + bool is_recent() const { + return type == Type::Recent; + } }; enum class DialogParticipantsFilter : int32 { Administrators, Members, Restricted, Banned, Bots };