Add td_api::chatMembersFilterContacts.
GitOrigin-RevId: 2f8f18da88a0de2c5df5bd1d0207d424b6b4e89b
This commit is contained in:
parent
b641382eab
commit
b4b9778947
@ -373,6 +373,9 @@ chatMembers total_count:int32 members:vector<chatMember> = ChatMembers;
|
||||
|
||||
//@class ChatMembersFilter @description Specifies the kind of chat members to return in searchChatMembers
|
||||
|
||||
//@description Returns contacts of the user
|
||||
chatMembersFilterContacts = ChatMembersFilter;
|
||||
|
||||
//@description Returns the creator and administrators
|
||||
chatMembersFilterAdministrators = ChatMembersFilter;
|
||||
|
||||
@ -394,7 +397,7 @@ 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
|
||||
//@description Returns contacts of the user, which are members of the supergroup or channel @query Query to search for
|
||||
supergroupMembersFilterContacts query:string = SupergroupMembersFilter;
|
||||
|
||||
//@description Returns the creator and administrators
|
||||
|
Binary file not shown.
@ -7644,7 +7644,8 @@ void ContactsManager::on_get_channel_participants_success(
|
||||
(filter.is_contacts() && !is_user_contact(result.back().user_id)) ||
|
||||
(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);
|
||||
bool skip_error = (filter.is_administrators() && is_user_deleted(result.back().user_id)) ||
|
||||
(filter.is_contacts() && result.back().user_id == get_my_id());
|
||||
if (!skip_error) {
|
||||
LOG(ERROR) << "Receive " << result.back() << ", while searching for " << filter << " in " << channel_id
|
||||
<< " with offset " << offset << " and limit " << limit;
|
||||
@ -9663,6 +9664,8 @@ std::pair<int32, vector<DialogParticipant>> ContactsManager::search_chat_partici
|
||||
|
||||
auto is_dialog_participant_suitable = [this](const DialogParticipant &participant, DialogParticipantsFilter filter) {
|
||||
switch (filter) {
|
||||
case DialogParticipantsFilter::Contacts:
|
||||
return is_user_contact(participant.user_id);
|
||||
case DialogParticipantsFilter::Administrators:
|
||||
return participant.status.is_administrator();
|
||||
case DialogParticipantsFilter::Members:
|
||||
|
@ -338,6 +338,8 @@ class ContactsManager : public Actor {
|
||||
|
||||
vector<DialogId> get_created_public_dialogs(Promise<Unit> &&promise);
|
||||
|
||||
bool is_user_contact(UserId user_id) const;
|
||||
|
||||
bool is_user_deleted(UserId user_id) const;
|
||||
|
||||
bool is_user_bot(UserId user_id) const;
|
||||
@ -990,8 +992,6 @@ class ContactsManager : public Actor {
|
||||
|
||||
bool is_chat_full_outdated(const ChatFull *chat_full, const Chat *c, ChatId chat_id) const;
|
||||
|
||||
bool is_user_contact(UserId user_id) const;
|
||||
|
||||
bool is_user_contact(const User *u, UserId user_id) const;
|
||||
|
||||
int32 get_user_was_online(const User *u, UserId user_id) const;
|
||||
|
@ -684,6 +684,8 @@ DialogParticipantsFilter get_dialog_participants_filter(const tl_object_ptr<td_a
|
||||
return DialogParticipantsFilter::Members;
|
||||
}
|
||||
switch (filter->get_id()) {
|
||||
case td_api::chatMembersFilterContacts::ID:
|
||||
return DialogParticipantsFilter::Contacts;
|
||||
case td_api::chatMembersFilterAdministrators::ID:
|
||||
return DialogParticipantsFilter::Administrators;
|
||||
case td_api::chatMembersFilterMembers::ID:
|
||||
|
@ -400,7 +400,7 @@ class ChannelParticipantsFilter {
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const ChannelParticipantsFilter &filter);
|
||||
|
||||
enum class DialogParticipantsFilter : int32 { Administrators, Members, Restricted, Banned, Bots };
|
||||
enum class DialogParticipantsFilter : int32 { Contacts, Administrators, Members, Restricted, Banned, Bots };
|
||||
|
||||
DialogParticipantsFilter get_dialog_participants_filter(const tl_object_ptr<td_api::ChatMembersFilter> &filter);
|
||||
|
||||
|
@ -21824,6 +21824,11 @@ std::pair<int32, vector<DialogParticipant>> MessagesManager::search_private_chat
|
||||
UserId my_user_id, UserId peer_user_id, const string &query, int32 limit, DialogParticipantsFilter filter) const {
|
||||
vector<UserId> user_ids;
|
||||
switch (filter) {
|
||||
case DialogParticipantsFilter::Contacts:
|
||||
if (td_->contacts_manager_->is_user_contact(peer_user_id)) {
|
||||
user_ids.push_back(peer_user_id);
|
||||
}
|
||||
break;
|
||||
case DialogParticipantsFilter::Administrators:
|
||||
break;
|
||||
case DialogParticipantsFilter::Members:
|
||||
@ -21879,11 +21884,11 @@ std::pair<int32, vector<DialogParticipant>> MessagesManager::search_dialog_parti
|
||||
string additional_query;
|
||||
int32 additional_limit = 0;
|
||||
switch (filter) {
|
||||
case DialogParticipantsFilter::Contacts:
|
||||
request_filter = td_api::make_object<td_api::supergroupMembersFilterContacts>();
|
||||
break;
|
||||
case DialogParticipantsFilter::Administrators:
|
||||
request_filter = td_api::make_object<td_api::supergroupMembersFilterAdministrators>();
|
||||
additional_query = query;
|
||||
additional_limit = limit;
|
||||
limit = 100;
|
||||
break;
|
||||
case DialogParticipantsFilter::Members:
|
||||
request_filter = td_api::make_object<td_api::supergroupMembersFilterSearch>(query);
|
||||
@ -21896,10 +21901,23 @@ std::pair<int32, vector<DialogParticipant>> MessagesManager::search_dialog_parti
|
||||
break;
|
||||
case DialogParticipantsFilter::Bots:
|
||||
request_filter = td_api::make_object<td_api::supergroupMembersFilterBots>();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
switch (filter) {
|
||||
case DialogParticipantsFilter::Contacts:
|
||||
case DialogParticipantsFilter::Administrators:
|
||||
case DialogParticipantsFilter::Bots:
|
||||
additional_query = query;
|
||||
additional_limit = limit;
|
||||
limit = 100;
|
||||
break;
|
||||
case DialogParticipantsFilter::Members:
|
||||
case DialogParticipantsFilter::Restricted:
|
||||
case DialogParticipantsFilter::Banned:
|
||||
// query is passed to the server request
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
@ -986,6 +986,9 @@ class CliClient final : public Actor {
|
||||
if (filter == "bot" || filter == "bots") {
|
||||
return td_api::make_object<td_api::chatMembersFilterBots>();
|
||||
}
|
||||
if (filter == "c" || filter == "contacts") {
|
||||
return td_api::make_object<td_api::chatMembersFilterContacts>();
|
||||
}
|
||||
if (filter == "m" || filter == "members") {
|
||||
return td_api::make_object<td_api::chatMembersFilterMembers>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user