Rewrite searchChatMembers and getSupergroupMembers implementation.
This commit is contained in:
parent
60673fea78
commit
d25edad06d
@ -2429,30 +2429,23 @@ class GetChannelParticipantQuery : public Td::ResultHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class GetChannelParticipantsQuery : public Td::ResultHandler {
|
class GetChannelParticipantsQuery : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<tl_object_ptr<telegram_api::channels_channelParticipants>> promise_;
|
||||||
ChannelId channel_id_;
|
ChannelId channel_id_;
|
||||||
ChannelParticipantsFilter filter_{nullptr};
|
|
||||||
int32 offset_;
|
|
||||||
int32 limit_;
|
|
||||||
int64 random_id_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GetChannelParticipantsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit GetChannelParticipantsQuery(Promise<tl_object_ptr<telegram_api::channels_channelParticipants>> &&promise)
|
||||||
|
: promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, int32 limit, int64 random_id) {
|
void send(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, int32 limit) {
|
||||||
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
|
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
|
||||||
if (input_channel == nullptr) {
|
if (input_channel == nullptr) {
|
||||||
return promise_.set_error(Status::Error(3, "Supergroup not found"));
|
return promise_.set_error(Status::Error(3, "Supergroup not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_id_ = channel_id;
|
channel_id_ = channel_id;
|
||||||
filter_ = std::move(filter);
|
|
||||||
offset_ = offset;
|
|
||||||
limit_ = limit;
|
|
||||||
random_id_ = random_id;
|
|
||||||
send_query(G()->net_query_creator().create(telegram_api::channels_getParticipants(
|
send_query(G()->net_query_creator().create(telegram_api::channels_getParticipants(
|
||||||
std::move(input_channel), filter_.get_input_channel_participants_filter(), offset, limit, 0)));
|
std::move(input_channel), filter.get_input_channel_participants_filter(), offset, limit, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -2462,31 +2455,22 @@ class GetChannelParticipantsQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto participants_ptr = result_ptr.move_as_ok();
|
auto participants_ptr = result_ptr.move_as_ok();
|
||||||
LOG(INFO) << "Receive result for GetChannelParticipantsQuery with filter "
|
LOG(INFO) << "Receive result for GetChannelParticipantsQuery: " << to_string(participants_ptr);
|
||||||
<< to_string(filter_.get_input_channel_participants_filter()) << ": " << to_string(participants_ptr);
|
|
||||||
switch (participants_ptr->get_id()) {
|
switch (participants_ptr->get_id()) {
|
||||||
case telegram_api::channels_channelParticipants::ID: {
|
case telegram_api::channels_channelParticipants::ID: {
|
||||||
auto participants = telegram_api::move_object_as<telegram_api::channels_channelParticipants>(participants_ptr);
|
promise_.set_value(telegram_api::move_object_as<telegram_api::channels_channelParticipants>(participants_ptr));
|
||||||
td->contacts_manager_->on_get_users(std::move(participants->users_), "GetChannelParticipantsQuery");
|
|
||||||
td->contacts_manager_->on_get_channel_participants_success(channel_id_, std::move(filter_), offset_, limit_,
|
|
||||||
random_id_, participants->count_,
|
|
||||||
std::move(participants->participants_));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case telegram_api::channels_channelParticipantsNotModified::ID:
|
case telegram_api::channels_channelParticipantsNotModified::ID:
|
||||||
LOG(ERROR) << "Receive channelParticipantsNotModified";
|
LOG(ERROR) << "Receive channelParticipantsNotModified";
|
||||||
break;
|
return on_error(id, Status::Error(500, "Receive channelParticipantsNotModified"));
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
promise_.set_value(Unit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(uint64 id, Status status) override {
|
void on_error(uint64 id, Status status) override {
|
||||||
td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantsQuery");
|
td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantsQuery");
|
||||||
td->contacts_manager_->on_get_channel_participants_fail(channel_id_, std::move(filter_), offset_, limit_,
|
|
||||||
random_id_);
|
|
||||||
promise_.set_error(std::move(status));
|
promise_.set_error(std::move(status));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -10627,9 +10611,17 @@ bool ContactsManager::is_user_contact(const User *u, UserId user_id, bool is_mut
|
|||||||
return u != nullptr && (is_mutual ? u->is_mutual_contact : u->is_contact) && user_id != get_my_id();
|
return u != nullptr && (is_mutual ? u->is_mutual_contact : u->is_contact) && user_id != get_my_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::on_get_channel_participants_success(
|
void ContactsManager::on_get_channel_participants(
|
||||||
ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, int32 limit, int64 random_id,
|
ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, int32 limit, string additional_query,
|
||||||
int32 total_count, vector<tl_object_ptr<telegram_api::ChannelParticipant>> &&participants) {
|
int32 additional_limit, tl_object_ptr<telegram_api::channels_channelParticipants> &&channel_participants,
|
||||||
|
Promise<DialogParticipants> &&promise) {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return promise.set_error(Status::Error(500, "Request aborted"));
|
||||||
|
}
|
||||||
|
|
||||||
|
on_get_users(std::move(channel_participants->users_), "on_get_channel_participants");
|
||||||
|
int32 total_count = channel_participants->count_;
|
||||||
|
auto participants = std::move(channel_participants->participants_);
|
||||||
LOG(INFO) << "Receive " << participants.size() << " members in " << channel_id;
|
LOG(INFO) << "Receive " << participants.size() << " members in " << channel_id;
|
||||||
|
|
||||||
bool is_full = offset == 0 && static_cast<int32>(participants.size()) < limit && total_count < limit;
|
bool is_full = offset == 0 && static_cast<int32>(participants.size()) < limit && total_count < limit;
|
||||||
@ -10738,17 +10730,24 @@ void ContactsManager::on_get_channel_participants_success(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (random_id != 0) {
|
if (!additional_query.empty()) {
|
||||||
received_channel_participants_[random_id] = {total_count, std::move(result)};
|
auto user_ids = transform(result, [](const auto &participant) { return participant.user_id; });
|
||||||
}
|
std::pair<int32, vector<UserId>> result_user_ids = search_among_users(user_ids, additional_query, additional_limit);
|
||||||
}
|
|
||||||
|
|
||||||
void ContactsManager::on_get_channel_participants_fail(ChannelId channel_id, ChannelParticipantsFilter filter,
|
total_count = result_user_ids.first;
|
||||||
int32 offset, int32 limit, int64 random_id) {
|
std::unordered_set<UserId, UserIdHash> result_user_ids_set(result_user_ids.second.begin(),
|
||||||
if (random_id != 0) {
|
result_user_ids.second.end());
|
||||||
// clean up
|
auto all_participants = std::move(result);
|
||||||
received_channel_participants_.erase(random_id);
|
result.clear();
|
||||||
|
for (auto &participant : all_participants) {
|
||||||
|
if (result_user_ids_set.count(participant.user_id)) {
|
||||||
|
result.push_back(std::move(participant));
|
||||||
|
result_user_ids_set.erase(participant.user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
promise.set_value(DialogParticipants{total_count, std::move(result)});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsManager::speculative_add_count(int32 &count, int32 delta_count, int32 min_count) {
|
bool ContactsManager::speculative_add_count(int32 &count, int32 delta_count, int32 min_count) {
|
||||||
@ -11247,13 +11246,16 @@ void ContactsManager::on_update_channel_full_linked_channel_id(ChannelFull *chan
|
|||||||
td_->messages_manager_->on_dialog_linked_channel_updated(DialogId(channel_id), old_linked_channel_id,
|
td_->messages_manager_->on_dialog_linked_channel_updated(DialogId(channel_id), old_linked_channel_id,
|
||||||
linked_channel_id);
|
linked_channel_id);
|
||||||
}
|
}
|
||||||
auto new_linked_linked_channel_id = get_linked_channel_id(linked_channel_id);
|
|
||||||
LOG(INFO) << "Uplate linked channel in " << linked_channel_id << " from " << old_linked_linked_channel_id << " to "
|
if (linked_channel_id.is_valid()) {
|
||||||
<< new_linked_linked_channel_id;
|
auto new_linked_linked_channel_id = get_linked_channel_id(linked_channel_id);
|
||||||
if (old_linked_linked_channel_id != new_linked_linked_channel_id) {
|
LOG(INFO) << "Uplate linked channel in " << linked_channel_id << " from " << old_linked_linked_channel_id << " to "
|
||||||
// must be called after the linked channel is changed
|
<< new_linked_linked_channel_id;
|
||||||
td_->messages_manager_->on_dialog_linked_channel_updated(DialogId(linked_channel_id), old_linked_linked_channel_id,
|
if (old_linked_linked_channel_id != new_linked_linked_channel_id) {
|
||||||
new_linked_linked_channel_id);
|
// must be called after the linked channel is changed
|
||||||
|
td_->messages_manager_->on_dialog_linked_channel_updated(
|
||||||
|
DialogId(linked_channel_id), old_linked_linked_channel_id, new_linked_linked_channel_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13401,24 +13403,34 @@ DialogParticipant ContactsManager::get_chat_participant(ChatId chat_id, UserId u
|
|||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipants ContactsManager::search_chat_participants(ChatId chat_id, const string &query, int32 limit,
|
void ContactsManager::search_chat_participants(ChatId chat_id, const string &query, int32 limit,
|
||||||
DialogParticipantsFilter filter, bool force,
|
DialogParticipantsFilter filter, Promise<DialogParticipants> &&promise) {
|
||||||
Promise<Unit> &&promise) {
|
|
||||||
if (limit < 0) {
|
if (limit < 0) {
|
||||||
promise.set_error(Status::Error(3, "Parameter limit must be non-negative"));
|
return promise.set_error(Status::Error(3, "Parameter limit must be non-negative"));
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force) {
|
auto load_chat_full_promise = PromiseCreator::lambda([actor_id = actor_id(this), chat_id, query, limit, filter,
|
||||||
promise.set_value(Unit());
|
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||||
} else if (!load_chat_full(chat_id, force, std::move(promise), "search_chat_participants")) {
|
if (result.is_error()) {
|
||||||
return {};
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
send_closure(actor_id, &ContactsManager::do_search_chat_participants, chat_id, query, limit, filter,
|
||||||
|
std::move(promise));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
load_chat_full(chat_id, false, std::move(load_chat_full_promise), "search_chat_participants");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactsManager::do_search_chat_participants(ChatId chat_id, const string &query, int32 limit,
|
||||||
|
DialogParticipantsFilter filter,
|
||||||
|
Promise<DialogParticipants> &&promise) {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return promise.set_error(Status::Error(500, "Request aborted"));
|
||||||
}
|
}
|
||||||
// promise is already set
|
|
||||||
|
|
||||||
auto chat_full = get_chat_full(chat_id);
|
auto chat_full = get_chat_full(chat_id);
|
||||||
if (chat_full == nullptr) {
|
if (chat_full == nullptr) {
|
||||||
return {};
|
return promise.set_error(Status::Error(500, "Can't find basic group full info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_dialog_participant_suitable = [this, filter](const DialogParticipant &participant) {
|
auto is_dialog_participant_suitable = [this, filter](const DialogParticipant &participant) {
|
||||||
@ -13452,7 +13464,9 @@ DialogParticipants ContactsManager::search_chat_participants(ChatId chat_id, con
|
|||||||
|
|
||||||
int32 total_count;
|
int32 total_count;
|
||||||
std::tie(total_count, user_ids) = search_among_users(user_ids, query, limit);
|
std::tie(total_count, user_ids) = search_among_users(user_ids, query, limit);
|
||||||
return {total_count, transform(user_ids, [&](UserId user_id) { return *get_chat_participant(chat_full, user_id); })};
|
promise.set_value(DialogParticipants{total_count, transform(user_ids, [this, chat_full](UserId user_id) {
|
||||||
|
return *get_chat_participant(chat_full, user_id);
|
||||||
|
})});
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id, UserId user_id, int64 &random_id,
|
DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id, UserId user_id, int64 &random_id,
|
||||||
@ -13516,88 +13530,69 @@ DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id,
|
|||||||
return DialogParticipant();
|
return DialogParticipant();
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipants ContactsManager::get_channel_participants(
|
void ContactsManager::get_channel_participants(ChannelId channel_id,
|
||||||
ChannelId channel_id, const tl_object_ptr<td_api::SupergroupMembersFilter> &filter, const string &additional_query,
|
tl_object_ptr<td_api::SupergroupMembersFilter> &&filter,
|
||||||
int32 offset, int32 limit, int32 additional_limit, int64 &random_id, bool without_bot_info, bool force,
|
string additional_query, int32 offset, int32 limit,
|
||||||
Promise<Unit> &&promise) {
|
int32 additional_limit, bool without_bot_info,
|
||||||
if (random_id != 0) {
|
Promise<DialogParticipants> &&promise) {
|
||||||
// request has already been sent before
|
|
||||||
auto it = received_channel_participants_.find(random_id);
|
|
||||||
CHECK(it != received_channel_participants_.end());
|
|
||||||
auto result = std::move(it->second);
|
|
||||||
received_channel_participants_.erase(it);
|
|
||||||
promise.set_value(Unit());
|
|
||||||
|
|
||||||
if (additional_query.empty()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto user_ids = transform(result.participants_, [](const auto &participant) { return participant.user_id; });
|
|
||||||
std::pair<int32, vector<UserId>> result_user_ids = search_among_users(user_ids, additional_query, additional_limit);
|
|
||||||
|
|
||||||
result.total_count_ = result_user_ids.first;
|
|
||||||
std::unordered_set<UserId, UserIdHash> result_user_ids_set(result_user_ids.second.begin(),
|
|
||||||
result_user_ids.second.end());
|
|
||||||
auto all_participants = std::move(result.participants_);
|
|
||||||
result.participants_.clear();
|
|
||||||
for (auto &participant : all_participants) {
|
|
||||||
if (result_user_ids_set.count(participant.user_id)) {
|
|
||||||
result.participants_.push_back(std::move(participant));
|
|
||||||
result_user_ids_set.erase(participant.user_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogParticipants result;
|
|
||||||
if (limit <= 0) {
|
if (limit <= 0) {
|
||||||
promise.set_error(Status::Error(3, "Parameter limit must be positive"));
|
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
if (limit > MAX_GET_CHANNEL_PARTICIPANTS) {
|
if (limit > MAX_GET_CHANNEL_PARTICIPANTS) {
|
||||||
limit = MAX_GET_CHANNEL_PARTICIPANTS;
|
limit = MAX_GET_CHANNEL_PARTICIPANTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
promise.set_error(Status::Error(3, "Parameter offset must be non-negative"));
|
return promise.set_error(Status::Error(400, "Parameter offset must be non-negative"));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto channel_full = get_channel_full_force(channel_id, "get_channel_participants");
|
auto load_channel_full_promise =
|
||||||
if (td_->auth_manager_->is_bot()) {
|
PromiseCreator::lambda([actor_id = actor_id(this), channel_id, filter = ChannelParticipantsFilter(filter),
|
||||||
without_bot_info = true;
|
additional_query = std::move(additional_query), offset, limit, additional_limit,
|
||||||
}
|
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||||
if (!without_bot_info && (channel_full == nullptr || (!force && channel_full->is_expired()))) {
|
if (result.is_error()) {
|
||||||
if (force) {
|
promise.set_error(result.move_as_error());
|
||||||
LOG(ERROR) << "Can't find cached ChannelFull";
|
} else {
|
||||||
} else {
|
send_closure(actor_id, &ContactsManager::do_get_channel_participants, channel_id, std::move(filter),
|
||||||
send_get_channel_full_query(channel_full, channel_id, std::move(promise), "get_channel_participants");
|
std::move(additional_query), offset, limit, additional_limit, std::move(promise));
|
||||||
return result;
|
}
|
||||||
|
});
|
||||||
|
if (!without_bot_info && !td_->auth_manager_->is_bot()) {
|
||||||
|
auto channel_full = get_channel_full_force(channel_id, "get_channel_participants");
|
||||||
|
if (channel_full == nullptr || channel_full->is_expired()) {
|
||||||
|
send_get_channel_full_query(channel_full, channel_id, std::move(load_channel_full_promise),
|
||||||
|
"get_channel_participants");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
load_channel_full_promise.set_value(Unit());
|
||||||
if (channel_full != nullptr && !channel_full->is_expired() && !channel_full->can_get_participants) {
|
|
||||||
promise.set_error(Status::Error(3, "Member list is inaccessible"));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
random_id = Random::secure_int64();
|
|
||||||
} while (random_id == 0 || received_channel_participants_.find(random_id) != received_channel_participants_.end());
|
|
||||||
received_channel_participants_[random_id]; // reserve place for result
|
|
||||||
|
|
||||||
send_get_channel_participants_query(channel_id, ChannelParticipantsFilter(filter), offset, limit, random_id,
|
|
||||||
std::move(promise));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::send_get_channel_participants_query(ChannelId channel_id, ChannelParticipantsFilter filter,
|
void ContactsManager::do_get_channel_participants(ChannelId channel_id, ChannelParticipantsFilter &&filter,
|
||||||
int32 offset, int32 limit, int64 random_id,
|
string additional_query, int32 offset, int32 limit,
|
||||||
Promise<Unit> &&promise) {
|
int32 additional_limit, Promise<DialogParticipants> &&promise) {
|
||||||
LOG(DEBUG) << "Get members of the " << channel_id << " with filter " << filter << ", offset = " << offset
|
if (G()->close_flag()) {
|
||||||
<< " and limit = " << limit;
|
return promise.set_error(Status::Error(500, "Request aborted"));
|
||||||
td_->create_handler<GetChannelParticipantsQuery>(std::move(promise))
|
}
|
||||||
->send(channel_id, std::move(filter), offset, limit, random_id);
|
|
||||||
|
auto channel_full = get_channel_full_force(channel_id, "do_get_channel_participants");
|
||||||
|
if (channel_full != nullptr && !channel_full->is_expired() && !channel_full->can_get_participants) {
|
||||||
|
return promise.set_error(Status::Error(400, "Member list is inaccessible"));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto get_channel_participants_promise = PromiseCreator::lambda(
|
||||||
|
[actor_id = actor_id(this), channel_id, filter, additional_query = std::move(additional_query), offset, limit,
|
||||||
|
additional_limit, promise = std::move(promise)](
|
||||||
|
Result<tl_object_ptr<telegram_api::channels_channelParticipants>> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
send_closure(actor_id, &ContactsManager::on_get_channel_participants, channel_id, std::move(filter), offset,
|
||||||
|
limit, std::move(additional_query), additional_limit, result.move_as_ok(), std::move(promise));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
td_->create_handler<GetChannelParticipantsQuery>(std::move(get_channel_participants_promise))
|
||||||
|
->send(channel_id, std::move(filter), offset, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<DialogAdministrator> ContactsManager::get_dialog_administrators(DialogId dialog_id, int left_tries,
|
vector<DialogAdministrator> ContactsManager::get_dialog_administrators(DialogId dialog_id, int left_tries,
|
||||||
|
@ -220,13 +220,6 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
bool on_get_channel_error(ChannelId channel_id, const Status &status, const string &source);
|
bool on_get_channel_error(ChannelId channel_id, const Status &status, const string &source);
|
||||||
|
|
||||||
void on_get_channel_participants_success(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset,
|
|
||||||
int32 limit, int64 random_id, int32 total_count,
|
|
||||||
vector<tl_object_ptr<telegram_api::ChannelParticipant>> &&participants);
|
|
||||||
|
|
||||||
void on_get_channel_participants_fail(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset,
|
|
||||||
int32 limit, int64 random_id);
|
|
||||||
|
|
||||||
static Slice get_dialog_invite_link_hash(const string &invite_link);
|
static Slice get_dialog_invite_link_hash(const string &invite_link);
|
||||||
|
|
||||||
void on_get_chat_invite_link(ChatId chat_id, tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link_ptr);
|
void on_get_chat_invite_link(ChatId chat_id, tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link_ptr);
|
||||||
@ -501,20 +494,15 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
DialogParticipant get_chat_participant(ChatId chat_id, UserId user_id, bool force, Promise<Unit> &&promise);
|
DialogParticipant get_chat_participant(ChatId chat_id, UserId user_id, bool force, Promise<Unit> &&promise);
|
||||||
|
|
||||||
DialogParticipants search_chat_participants(ChatId chat_id, const string &query, int32 limit,
|
void search_chat_participants(ChatId chat_id, const string &query, int32 limit, DialogParticipantsFilter filter,
|
||||||
DialogParticipantsFilter filter, bool force, Promise<Unit> &&promise);
|
Promise<DialogParticipants> &&promise);
|
||||||
|
|
||||||
DialogParticipant get_channel_participant(ChannelId channel_id, UserId user_id, int64 &random_id, bool force,
|
DialogParticipant get_channel_participant(ChannelId channel_id, UserId user_id, int64 &random_id, bool force,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
DialogParticipants get_channel_participants(ChannelId channel_id,
|
void get_channel_participants(ChannelId channel_id, tl_object_ptr<td_api::SupergroupMembersFilter> &&filter,
|
||||||
const tl_object_ptr<td_api::SupergroupMembersFilter> &filter,
|
string additional_query, int32 offset, int32 limit, int32 additional_limit,
|
||||||
const string &additional_query, int32 offset, int32 limit,
|
bool without_bot_info, Promise<DialogParticipants> &&promise);
|
||||||
int32 additional_limit, int64 &random_id, bool without_bot_info,
|
|
||||||
bool force, Promise<Unit> &&promise);
|
|
||||||
|
|
||||||
void send_get_channel_participants_query(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset,
|
|
||||||
int32 limit, int64 random_id, Promise<Unit> &&promise);
|
|
||||||
|
|
||||||
DialogParticipant get_dialog_participant(ChannelId channel_id,
|
DialogParticipant get_dialog_participant(ChannelId channel_id,
|
||||||
tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr) const;
|
tl_object_ptr<telegram_api::ChannelParticipant> &&participant_ptr) const;
|
||||||
@ -1425,6 +1413,18 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
void delete_chat_participant(ChatId chat_id, UserId user_id, Promise<Unit> &&promise);
|
void delete_chat_participant(ChatId chat_id, UserId user_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void do_search_chat_participants(ChatId chat_id, const string &query, int32 limit, DialogParticipantsFilter filter,
|
||||||
|
Promise<DialogParticipants> &&promise);
|
||||||
|
|
||||||
|
void do_get_channel_participants(ChannelId channel_id, ChannelParticipantsFilter &&filter, string additional_query,
|
||||||
|
int32 offset, int32 limit, int32 additional_limit,
|
||||||
|
Promise<DialogParticipants> &&promise);
|
||||||
|
|
||||||
|
void on_get_channel_participants(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, int32 limit,
|
||||||
|
string additional_query, int32 additional_limit,
|
||||||
|
tl_object_ptr<telegram_api::channels_channelParticipants> &&channel_participants,
|
||||||
|
Promise<DialogParticipants> &&promise);
|
||||||
|
|
||||||
void change_channel_participant_status_impl(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
void change_channel_participant_status_impl(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
||||||
DialogParticipantStatus old_status, Promise<Unit> &&promise);
|
DialogParticipantStatus old_status, Promise<Unit> &&promise);
|
||||||
|
|
||||||
@ -1567,7 +1567,6 @@ class ContactsManager : public Actor {
|
|||||||
std::unordered_map<int64, std::pair<vector<UserId>, vector<int32>>> imported_contacts_;
|
std::unordered_map<int64, std::pair<vector<UserId>, vector<int32>>> imported_contacts_;
|
||||||
|
|
||||||
std::unordered_map<int64, DialogParticipant> received_channel_participant_;
|
std::unordered_map<int64, DialogParticipant> received_channel_participant_;
|
||||||
std::unordered_map<int64, DialogParticipants> received_channel_participants_;
|
|
||||||
|
|
||||||
std::unordered_map<ChannelId, vector<DialogParticipant>, ChannelIdHash> cached_channel_participants_;
|
std::unordered_map<ChannelId, vector<DialogParticipant>, ChannelIdHash> cached_channel_participants_;
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "td/telegram/AccessRights.h"
|
#include "td/telegram/AccessRights.h"
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
#include "td/telegram/DialogParticipant.h"
|
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/MessagesManager.h"
|
#include "td/telegram/MessagesManager.h"
|
||||||
@ -1483,23 +1482,29 @@ void GroupCallManager::try_load_group_call_administrators(InputGroupCallId input
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<int64> random_id_ptr = td::make_unique<int64>();
|
auto promise =
|
||||||
auto random_id_raw = random_id_ptr.get();
|
PromiseCreator::lambda([actor_id = actor_id(this), input_group_call_id](Result<DialogParticipants> &&result) {
|
||||||
auto promise = PromiseCreator::lambda(
|
|
||||||
[actor_id = actor_id(this), input_group_call_id, random_id = std::move(random_id_ptr)](Result<Unit> &&result) {
|
|
||||||
send_closure(actor_id, &GroupCallManager::finish_load_group_call_administrators, input_group_call_id,
|
send_closure(actor_id, &GroupCallManager::finish_load_group_call_administrators, input_group_call_id,
|
||||||
*random_id, std::move(result));
|
std::move(result));
|
||||||
});
|
});
|
||||||
td_->messages_manager_->search_dialog_participants(
|
td_->messages_manager_->search_dialog_participants(
|
||||||
dialog_id, string(), 100, DialogParticipantsFilter(DialogParticipantsFilter::Type::Administrators),
|
dialog_id, string(), 100, DialogParticipantsFilter(DialogParticipantsFilter::Type::Administrators), true,
|
||||||
*random_id_raw, true, true, std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCallManager::finish_load_group_call_administrators(InputGroupCallId input_group_call_id, int64 random_id,
|
void GroupCallManager::finish_load_group_call_administrators(InputGroupCallId input_group_call_id,
|
||||||
Result<Unit> &&result) {
|
Result<DialogParticipants> &&result) {
|
||||||
if (G()->close_flag()) {
|
if (G()->close_flag()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (result.is_error()) {
|
||||||
|
LOG(WARNING) << "Failed to get administrators of " << input_group_call_id << ": " << result.error();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!need_group_call_participants(input_group_call_id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto *group_call = get_group_call(input_group_call_id);
|
auto *group_call = get_group_call(input_group_call_id);
|
||||||
CHECK(group_call != nullptr);
|
CHECK(group_call != nullptr);
|
||||||
@ -1508,34 +1513,11 @@ void GroupCallManager::finish_load_group_call_administrators(InputGroupCallId in
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<UserId> administrator_user_ids;
|
vector<UserId> administrator_user_ids;
|
||||||
if (result.is_ok()) {
|
auto participants = result.move_as_ok();
|
||||||
result = Status::Error(500, "Failed to receive result");
|
for (auto &administrator : participants.participants_) {
|
||||||
unique_ptr<bool> ignore_result = make_unique<bool>();
|
if (administrator.status.can_manage_calls() && administrator.user_id != td_->contacts_manager_->get_my_id()) {
|
||||||
auto ignore_result_ptr = ignore_result.get();
|
administrator_user_ids.push_back(administrator.user_id);
|
||||||
auto promise = PromiseCreator::lambda([&result, ignore_result = std::move(ignore_result)](Result<Unit> new_result) {
|
|
||||||
if (!*ignore_result) {
|
|
||||||
result = std::move(new_result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
auto participants = td_->messages_manager_->search_dialog_participants(
|
|
||||||
group_call->dialog_id, string(), 100, DialogParticipantsFilter(DialogParticipantsFilter::Type::Administrators),
|
|
||||||
random_id, true, true, std::move(promise));
|
|
||||||
for (auto &administrator : participants.participants_) {
|
|
||||||
if (administrator.status.can_manage_calls() && administrator.user_id != td_->contacts_manager_->get_my_id()) {
|
|
||||||
administrator_user_ids.push_back(administrator.user_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*ignore_result_ptr = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.is_error()) {
|
|
||||||
LOG(WARNING) << "Failed to get administrators of " << input_group_call_id << ": " << result.error();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!need_group_call_participants(input_group_call_id)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *group_call_participants = add_group_call_participants(input_group_call_id);
|
auto *group_call_participants = add_group_call_participants(input_group_call_id);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
|
#include "td/telegram/DialogParticipant.h"
|
||||||
#include "td/telegram/GroupCallId.h"
|
#include "td/telegram/GroupCallId.h"
|
||||||
#include "td/telegram/GroupCallParticipant.h"
|
#include "td/telegram/GroupCallParticipant.h"
|
||||||
#include "td/telegram/InputGroupCallId.h"
|
#include "td/telegram/InputGroupCallId.h"
|
||||||
@ -151,8 +152,7 @@ class GroupCallManager : public Actor {
|
|||||||
|
|
||||||
void try_load_group_call_administrators(InputGroupCallId input_group_call_id, DialogId dialog_id);
|
void try_load_group_call_administrators(InputGroupCallId input_group_call_id, DialogId dialog_id);
|
||||||
|
|
||||||
void finish_load_group_call_administrators(InputGroupCallId input_group_call_id, int64 random_id,
|
void finish_load_group_call_administrators(InputGroupCallId input_group_call_id, Result<DialogParticipants> &&result);
|
||||||
Result<Unit> &&result);
|
|
||||||
|
|
||||||
bool on_join_group_call_response(InputGroupCallId input_group_call_id, string json_response);
|
bool on_join_group_call_response(InputGroupCallId input_group_call_id, string json_response);
|
||||||
|
|
||||||
|
@ -11275,9 +11275,9 @@ void MessagesManager::on_update_dialog_online_member_count_timeout(DialogId dial
|
|||||||
if (participant_count == 0 || participant_count >= 195) {
|
if (participant_count == 0 || participant_count >= 195) {
|
||||||
td_->create_handler<GetOnlinesQuery>()->send(dialog_id);
|
td_->create_handler<GetOnlinesQuery>()->send(dialog_id);
|
||||||
} else {
|
} else {
|
||||||
td_->contacts_manager_->send_get_channel_participants_query(
|
td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(),
|
||||||
dialog_id.get_channel_id(),
|
td_api::make_object<td_api::supergroupMembersFilterRecent>(),
|
||||||
ChannelParticipantsFilter(td_api::make_object<td_api::supergroupMembersFilterRecent>()), 0, 200, 0, Auto());
|
string(), 0, 200, 200, true, Auto());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -18927,10 +18927,9 @@ void MessagesManager::open_dialog(Dialog *d) {
|
|||||||
if (!is_broadcast_channel(dialog_id)) {
|
if (!is_broadcast_channel(dialog_id)) {
|
||||||
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
|
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
|
||||||
if (participant_count < 195) { // include unknown participant_count
|
if (participant_count < 195) { // include unknown participant_count
|
||||||
td_->contacts_manager_->send_get_channel_participants_query(
|
td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(),
|
||||||
dialog_id.get_channel_id(),
|
td_api::make_object<td_api::supergroupMembersFilterRecent>(),
|
||||||
ChannelParticipantsFilter(td_api::make_object<td_api::supergroupMembersFilterRecent>()), 0, 200, 0,
|
string(), 0, 200, 200, true, Auto());
|
||||||
Auto());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get_channel_difference(dialog_id, d->pts, true, "open_dialog");
|
get_channel_difference(dialog_id, d->pts, true, "open_dialog");
|
||||||
@ -30308,28 +30307,25 @@ DialogParticipants MessagesManager::search_private_chat_participants(UserId my_u
|
|||||||
})};
|
})};
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipants MessagesManager::search_dialog_participants(DialogId dialog_id, const string &query, int32 limit,
|
void MessagesManager::search_dialog_participants(DialogId dialog_id, const string &query, int32 limit,
|
||||||
DialogParticipantsFilter filter, int64 &random_id,
|
DialogParticipantsFilter filter, bool without_bot_info,
|
||||||
bool without_bot_info, bool force,
|
Promise<DialogParticipants> &&promise) {
|
||||||
Promise<Unit> &&promise) {
|
|
||||||
LOG(INFO) << "Receive searchChatMembers request to search for \"" << query << "\" in " << dialog_id << " with filter "
|
LOG(INFO) << "Receive searchChatMembers request to search for \"" << query << "\" in " << dialog_id << " with filter "
|
||||||
<< filter;
|
<< filter;
|
||||||
if (!have_dialog_force(dialog_id)) {
|
if (!have_dialog_force(dialog_id)) {
|
||||||
promise.set_error(Status::Error(3, "Chat not found"));
|
return promise.set_error(Status::Error(3, "Chat not found"));
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
if (limit < 0) {
|
if (limit < 0) {
|
||||||
promise.set_error(Status::Error(3, "Parameter limit must be non-negative"));
|
return promise.set_error(Status::Error(3, "Parameter limit must be non-negative"));
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
promise.set_value(Unit());
|
promise.set_value(search_private_chat_participants(td_->contacts_manager_->get_my_id(), dialog_id.get_user_id(),
|
||||||
return search_private_chat_participants(td_->contacts_manager_->get_my_id(), dialog_id.get_user_id(), query,
|
query, limit, filter));
|
||||||
limit, filter);
|
return;
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
return td_->contacts_manager_->search_chat_participants(dialog_id.get_chat_id(), query, limit, filter, force,
|
return td_->contacts_manager_->search_chat_participants(dialog_id.get_chat_id(), query, limit, filter,
|
||||||
std::move(promise));
|
std::move(promise));
|
||||||
case DialogType::Channel: {
|
case DialogType::Channel: {
|
||||||
tl_object_ptr<td_api::SupergroupMembersFilter> request_filter;
|
tl_object_ptr<td_api::SupergroupMembersFilter> request_filter;
|
||||||
@ -30379,21 +30375,21 @@ DialogParticipants MessagesManager::search_dialog_participants(DialogId dialog_i
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
return td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(), request_filter,
|
return td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(), std::move(request_filter),
|
||||||
additional_query, 0, limit, additional_limit, random_id,
|
std::move(additional_query), 0, limit, additional_limit,
|
||||||
without_bot_info, force, std::move(promise));
|
without_bot_info, std::move(promise));
|
||||||
}
|
}
|
||||||
case DialogType::SecretChat: {
|
case DialogType::SecretChat: {
|
||||||
promise.set_value(Unit());
|
|
||||||
auto peer_user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
auto peer_user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||||
return search_private_chat_participants(td_->contacts_manager_->get_my_id(), peer_user_id, query, limit, filter);
|
promise.set_value(
|
||||||
|
search_private_chat_participants(td_->contacts_manager_->get_my_id(), peer_user_id, query, limit, filter));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case DialogType::None:
|
case DialogType::None:
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
promise.set_error(Status::Error(500, "Wrong chat type"));
|
promise.set_error(Status::Error(500, "Wrong chat type"));
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<DialogAdministrator> MessagesManager::get_dialog_administrators(DialogId dialog_id, int left_tries,
|
vector<DialogAdministrator> MessagesManager::get_dialog_administrators(DialogId dialog_id, int left_tries,
|
||||||
|
@ -477,9 +477,8 @@ class MessagesManager : public Actor {
|
|||||||
DialogParticipant get_dialog_participant(DialogId dialog_id, UserId user_id, int64 &random_id, bool force,
|
DialogParticipant get_dialog_participant(DialogId dialog_id, UserId user_id, int64 &random_id, bool force,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
DialogParticipants search_dialog_participants(DialogId dialog_id, const string &query, int32 limit,
|
void search_dialog_participants(DialogId dialog_id, const string &query, int32 limit, DialogParticipantsFilter filter,
|
||||||
DialogParticipantsFilter filter, int64 &random_id,
|
bool without_bot_info, Promise<DialogParticipants> &&promise);
|
||||||
bool without_bot_info, bool force, Promise<Unit> &&promise);
|
|
||||||
|
|
||||||
vector<DialogAdministrator> get_dialog_administrators(DialogId dialog_id, int left_tries, Promise<Unit> &&promise);
|
vector<DialogAdministrator> get_dialog_administrators(DialogId dialog_id, int left_tries, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -1961,36 +1961,6 @@ class GetChatMemberRequest : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SearchChatMembersRequest : public RequestActor<> {
|
|
||||||
DialogId dialog_id_;
|
|
||||||
string query_;
|
|
||||||
int32 limit_;
|
|
||||||
DialogParticipantsFilter filter_;
|
|
||||||
int64 random_id_ = 0;
|
|
||||||
|
|
||||||
DialogParticipants participants_;
|
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) override {
|
|
||||||
participants_ = td->messages_manager_->search_dialog_participants(dialog_id_, query_, limit_, filter_, random_id_,
|
|
||||||
false, get_tries() < 3, std::move(promise));
|
|
||||||
}
|
|
||||||
|
|
||||||
void do_send_result() override {
|
|
||||||
send_result(participants_.get_chat_members_object(td));
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
SearchChatMembersRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string &&query, int32 limit,
|
|
||||||
DialogParticipantsFilter filter)
|
|
||||||
: RequestActor(std::move(td), request_id)
|
|
||||||
, dialog_id_(dialog_id)
|
|
||||||
, query_(std::move(query))
|
|
||||||
, limit_(limit)
|
|
||||||
, filter_(filter) {
|
|
||||||
set_tries(3);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class GetChatAdministratorsRequest : public RequestActor<> {
|
class GetChatAdministratorsRequest : public RequestActor<> {
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
|
|
||||||
@ -2271,36 +2241,6 @@ class GetRecentInlineBotsRequest : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetSupergroupMembersRequest : public RequestActor<> {
|
|
||||||
ChannelId channel_id_;
|
|
||||||
tl_object_ptr<td_api::SupergroupMembersFilter> filter_;
|
|
||||||
int32 offset_;
|
|
||||||
int32 limit_;
|
|
||||||
int64 random_id_ = 0;
|
|
||||||
|
|
||||||
DialogParticipants participants_;
|
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) override {
|
|
||||||
participants_ = td->contacts_manager_->get_channel_participants(
|
|
||||||
channel_id_, filter_, string(), offset_, limit_, -1, random_id_, false, get_tries() < 3, std::move(promise));
|
|
||||||
}
|
|
||||||
|
|
||||||
void do_send_result() override {
|
|
||||||
send_result(participants_.get_chat_members_object(td));
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
GetSupergroupMembersRequest(ActorShared<Td> td, uint64 request_id, int32 channel_id,
|
|
||||||
tl_object_ptr<td_api::SupergroupMembersFilter> &&filter, int32 offset, int32 limit)
|
|
||||||
: RequestActor(std::move(td), request_id)
|
|
||||||
, channel_id_(channel_id)
|
|
||||||
, filter_(std::move(filter))
|
|
||||||
, offset_(offset)
|
|
||||||
, limit_(limit) {
|
|
||||||
set_tries(3);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class GetUserProfilePhotosRequest : public RequestActor<> {
|
class GetUserProfilePhotosRequest : public RequestActor<> {
|
||||||
UserId user_id_;
|
UserId user_id_;
|
||||||
int32 offset_;
|
int32 offset_;
|
||||||
@ -6327,8 +6267,18 @@ void Td::on_request(uint64 id, const td_api::getChatMember &request) {
|
|||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::searchChatMembers &request) {
|
void Td::on_request(uint64 id, td_api::searchChatMembers &request) {
|
||||||
CLEAN_INPUT_STRING(request.query_);
|
CLEAN_INPUT_STRING(request.query_);
|
||||||
CREATE_REQUEST(SearchChatMembersRequest, request.chat_id_, std::move(request.query_), request.limit_,
|
CREATE_REQUEST_PROMISE();
|
||||||
get_dialog_participants_filter(request.filter_));
|
auto query_promise =
|
||||||
|
PromiseCreator::lambda([promise = std::move(promise), td = this](Result<DialogParticipants> result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
promise.set_value(result.ok().get_chat_members_object(td));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
messages_manager_->search_dialog_participants(DialogId(request.chat_id_), request.query_, request.limit_,
|
||||||
|
get_dialog_participants_filter(request.filter_), false,
|
||||||
|
std::move(query_promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::getChatAdministrators &request) {
|
void Td::on_request(uint64 id, td_api::getChatAdministrators &request) {
|
||||||
@ -6691,8 +6641,17 @@ void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::getSupergroupMembers &request) {
|
void Td::on_request(uint64 id, td_api::getSupergroupMembers &request) {
|
||||||
CREATE_REQUEST(GetSupergroupMembersRequest, request.supergroup_id_, std::move(request.filter_), request.offset_,
|
CREATE_REQUEST_PROMISE();
|
||||||
request.limit_);
|
auto query_promise =
|
||||||
|
PromiseCreator::lambda([promise = std::move(promise), td = this](Result<DialogParticipants> result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
promise.set_value(result.ok().get_chat_members_object(td));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contacts_manager_->get_channel_participants(ChannelId(request.supergroup_id_), std::move(request.filter_), string(),
|
||||||
|
request.offset_, request.limit_, -1, false, std::move(query_promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::deleteSupergroup &request) {
|
void Td::on_request(uint64 id, const td_api::deleteSupergroup &request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user