diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 5c97cf0b..9a9ea3c5 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -7514,6 +7514,8 @@ void ContactsManager::on_get_channel_participants_success( int32 total_count, vector> &&participants) { LOG(INFO) << "Receive " << participants.size() << " members in " << channel_id; + bool is_full = offset == 0 && static_cast(participants.size()) < limit && total_count < limit; + vector result; for (auto &participant_ptr : participants) { result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr))); @@ -7532,14 +7534,16 @@ void ContactsManager::on_get_channel_participants_success( LOG(ERROR) << "Receive total_count = " << total_count << ", but have at least " << result.size() << " members in " << channel_id; total_count = static_cast(result.size()); + } else if (is_full && total_count > static_cast(result.size())) { + LOG(ERROR) << "Fix total member count from " << total_count << " to " << result.size(); + total_count = static_cast(result.size()); } const auto max_participant_count = get_channel_type(channel_id) == ChannelType::Megagroup ? 9950 : 195; auto participant_count = filter.is_recent() && total_count != 0 && total_count < max_participant_count ? total_count : -1; int32 administrator_count = filter.is_administrators() ? total_count : -1; - if (offset == 0 && static_cast(participants.size()) < limit && - (filter.is_administrators() || filter.is_bots() || filter.is_recent())) { + if (is_full && (filter.is_administrators() || filter.is_bots() || filter.is_recent())) { vector administrator_user_ids; vector bot_user_ids; { @@ -9541,6 +9545,9 @@ std::pair> ContactsManager::get_channel_partici promise.set_error(Status::Error(3, "Parameter limit must be positive")); return result; } + if (limit > MAX_GET_CHANNEL_PARTICIPANTS) { + limit = MAX_GET_CHANNEL_PARTICIPANTS; + } if (offset < 0) { promise.set_error(Status::Error(3, "Parameter offset must be non-negative")); diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 44096334..3b3b4f05 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -709,10 +709,11 @@ class ContactsManager : public Actor { class ChannelLogEvent; class SecretChatLogEvent; - static constexpr int32 MAX_GET_PROFILE_PHOTOS = 100; // server side limit - static constexpr size_t MAX_NAME_LENGTH = 64; // server side limit for first/last name - static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for channel description - static constexpr size_t MAX_BIO_LENGTH = 70; // server side limit + static constexpr int32 MAX_GET_PROFILE_PHOTOS = 100; // server side limit + static constexpr size_t MAX_NAME_LENGTH = 64; // server side limit for first/last name + static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for channel description + static constexpr size_t MAX_BIO_LENGTH = 70; // server side limit + static constexpr size_t MAX_GET_CHANNEL_PARTICIPANTS = 200; // server side limit static constexpr int32 USER_FLAG_HAS_ACCESS_HASH = 1 << 0; static constexpr int32 USER_FLAG_HAS_FIRST_NAME = 1 << 1;