Add supergroupMembersFilterContacts.

GitOrigin-RevId: 56dee642cebc5f71918be82219a39d4ad3e4f615
This commit is contained in:
levlam 2019-03-18 05:36:47 +03:00
parent ed3e4b7d67
commit bc736d0cc5
6 changed files with 20 additions and 5 deletions

View File

@ -389,6 +389,9 @@ chatMembersFilterBots = ChatMembersFilter;
//@description Returns recently active users in reverse chronological order
supergroupMembersFilterRecent = SupergroupMembersFilter;
//@description Returns contacts, which are members of the supergroup or channel @query Query to search for
supergroupMembersFilterContacts query:string = SupergroupMembersFilter;
//@description Returns the creator and administrators
supergroupMembersFilterAdministrators = SupergroupMembersFilter;

Binary file not shown.

View File

@ -7516,7 +7516,7 @@ void ContactsManager::on_get_channel_participants_success(
result.push_back(get_dialog_participant(channel_id, std::move(participant_ptr)));
if ((filter.is_bots() && !is_user_bot(result.back().user_id)) ||
(filter.is_administrators() && !result.back().status.is_administrator()) ||
((filter.is_recent() || filter.is_search()) && !result.back().status.is_member()) ||
((filter.is_recent() || filter.is_contacts() || filter.is_search()) && !result.back().status.is_member()) ||
(filter.is_restricted() && !result.back().status.is_restricted()) ||
(filter.is_banned() && !result.back().status.is_banned())) {
bool skip_error = filter.is_administrators() && is_user_deleted(result.back().user_id);

View File

@ -408,6 +408,8 @@ ChannelParticipantsFilter::get_input_channel_participants_filter() const {
switch (type) {
case Type::Recent:
return make_tl_object<telegram_api::channelParticipantsRecent>();
case Type::Contacts:
return make_tl_object<telegram_api::channelParticipantsContacts>(query);
case Type::Administrators:
return make_tl_object<telegram_api::channelParticipantsAdmins>();
case Type::Search:
@ -433,6 +435,10 @@ ChannelParticipantsFilter::ChannelParticipantsFilter(const tl_object_ptr<td_api:
case td_api::supergroupMembersFilterRecent::ID:
type = Type::Recent;
return;
case td_api::supergroupMembersFilterContacts::ID:
type = Type::Contacts;
query = static_cast<const td_api::supergroupMembersFilterContacts *>(filter.get())->query_;
return;
case td_api::supergroupMembersFilterAdministrators::ID:
type = Type::Administrators;
return;
@ -461,6 +467,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipan
switch (filter.type) {
case ChannelParticipantsFilter::Type::Recent:
return string_builder << "Recent";
case ChannelParticipantsFilter::Type::Contacts:
return string_builder << "Contacts \"" << filter.query << '"';
case ChannelParticipantsFilter::Type::Administrators:
return string_builder << "Administrators";
case ChannelParticipantsFilter::Type::Search:

View File

@ -256,7 +256,7 @@ struct DialogParticipant {
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant &dialog_participant);
class ChannelParticipantsFilter {
enum class Type : int32 { Recent, Administrators, Search, Restricted, Banned, Bots } type;
enum class Type : int32 { Recent, Contacts, Administrators, Search, Restricted, Banned, Bots } type;
string query;
friend StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter);
@ -278,6 +278,10 @@ class ChannelParticipantsFilter {
return type == Type::Recent;
}
bool is_contacts() const {
return type == Type::Contacts;
}
bool is_search() const {
return type == Type::Search;
}

View File

@ -2189,6 +2189,9 @@ class CliClient final : public Actor {
std::tie(chat_id, user_id) = split(args);
send_request(td_api::make_object<td_api::getChatMember>(as_chat_id(chat_id), as_user_id(user_id)));
} else if (op == "GetChatAdministrators") {
string chat_id = args;
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
} else if (op == "GetSupergroupAdministrators") {
string supergroup_id;
string offset;
@ -2205,9 +2208,6 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getSupergroupMembers>(
as_supergroup_id(supergroup_id), td_api::make_object<td_api::supergroupMembersFilterAdministrators>(),
to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "GetChatAdministrators") {
string chat_id = args;
send_request(td_api::make_object<td_api::getChatAdministrators>(as_chat_id(chat_id)));
} else if (op == "GetSupergroupBanned") {
string supergroup_id;
string query;