Add DialogParticipantsFilter::is_dialog_participant_suitable.
This commit is contained in:
parent
1c59f37ca9
commit
7d4442347d
@ -14946,32 +14946,9 @@ void ContactsManager::do_search_chat_participants(ChatId chat_id, const string &
|
||||
return promise.set_error(Status::Error(500, "Can't find basic group full info"));
|
||||
}
|
||||
|
||||
auto is_dialog_participant_suitable = [this, filter](const DialogParticipant &participant) {
|
||||
switch (filter.type_) {
|
||||
case DialogParticipantsFilter::Type::Contacts:
|
||||
return participant.dialog_id.get_type() == DialogType::User &&
|
||||
is_user_contact(participant.dialog_id.get_user_id());
|
||||
case DialogParticipantsFilter::Type::Administrators:
|
||||
return participant.status.is_administrator();
|
||||
case DialogParticipantsFilter::Type::Members:
|
||||
return participant.status.is_member(); // should be always true
|
||||
case DialogParticipantsFilter::Type::Restricted:
|
||||
return participant.status.is_restricted(); // should be always false
|
||||
case DialogParticipantsFilter::Type::Banned:
|
||||
return participant.status.is_banned(); // should be always false
|
||||
case DialogParticipantsFilter::Type::Mention:
|
||||
return true;
|
||||
case DialogParticipantsFilter::Type::Bots:
|
||||
return participant.dialog_id.get_type() == DialogType::User && is_user_bot(participant.dialog_id.get_user_id());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
vector<DialogId> dialog_ids;
|
||||
for (const auto &participant : chat_full->participants) {
|
||||
if (is_dialog_participant_suitable(participant)) {
|
||||
if (filter.is_dialog_participant_suitable(td_, participant)) {
|
||||
dialog_ids.push_back(participant.dialog_id);
|
||||
}
|
||||
}
|
||||
|
@ -975,4 +975,29 @@ bool DialogParticipantsFilter::has_query() const {
|
||||
}
|
||||
}
|
||||
|
||||
bool DialogParticipantsFilter::is_dialog_participant_suitable(const Td *td,
|
||||
const DialogParticipant &participant) const {
|
||||
switch (type_) {
|
||||
case Type::Contacts:
|
||||
return participant.dialog_id.get_type() == DialogType::User &&
|
||||
td->contacts_manager_->is_user_contact(participant.dialog_id.get_user_id());
|
||||
case Type::Administrators:
|
||||
return participant.status.is_administrator();
|
||||
case Type::Members:
|
||||
return participant.status.is_member();
|
||||
case Type::Restricted:
|
||||
return participant.status.is_restricted();
|
||||
case Type::Banned:
|
||||
return participant.status.is_banned();
|
||||
case Type::Mention:
|
||||
return true;
|
||||
case Type::Bots:
|
||||
return participant.dialog_id.get_type() == DialogType::User &&
|
||||
td->contacts_manager_->is_user_bot(participant.dialog_id.get_user_id());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -507,6 +507,8 @@ class DialogParticipantsFilter {
|
||||
td_api::object_ptr<td_api::SupergroupMembersFilter> get_supergroup_members_filter_object(const string &query) const;
|
||||
|
||||
bool has_query() const;
|
||||
|
||||
bool is_dialog_participant_suitable(const Td *td, const DialogParticipant &participant) const;
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipantsFilter &filter);
|
||||
|
Loading…
Reference in New Issue
Block a user