Allow loading channel participants without bot info.

This commit is contained in:
levlam 2020-12-16 17:43:34 +03:00
parent 92327f1fe7
commit 415a64ff24
5 changed files with 16 additions and 12 deletions

View File

@ -13492,7 +13492,8 @@ DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id,
std::pair<int32, vector<DialogParticipant>> ContactsManager::get_channel_participants( std::pair<int32, vector<DialogParticipant>> ContactsManager::get_channel_participants(
ChannelId channel_id, const tl_object_ptr<td_api::SupergroupMembersFilter> &filter, const string &additional_query, ChannelId channel_id, const tl_object_ptr<td_api::SupergroupMembersFilter> &filter, const string &additional_query,
int32 offset, int32 limit, int32 additional_limit, int64 &random_id, bool force, Promise<Unit> &&promise) { int32 offset, int32 limit, int32 additional_limit, int64 &random_id, bool without_bot_info, bool force,
Promise<Unit> &&promise) {
if (random_id != 0) { if (random_id != 0) {
// request has already been sent before // request has already been sent before
auto it = received_channel_participants_.find(random_id); auto it = received_channel_participants_.find(random_id);
@ -13537,7 +13538,10 @@ std::pair<int32, vector<DialogParticipant>> ContactsManager::get_channel_partici
} }
auto channel_full = get_channel_full_force(channel_id, "get_channel_participants"); auto channel_full = get_channel_full_force(channel_id, "get_channel_participants");
if (channel_full == nullptr || (!force && channel_full->is_expired())) { if (td_->auth_manager_->is_bot()) {
without_bot_info = true;
}
if (!without_bot_info && (channel_full == nullptr || (!force && channel_full->is_expired()))) {
if (force) { if (force) {
LOG(ERROR) << "Can't find cached ChannelFull"; LOG(ERROR) << "Can't find cached ChannelFull";
} else { } else {

View File

@ -509,8 +509,8 @@ class ContactsManager : public Actor {
std::pair<int32, vector<DialogParticipant>> get_channel_participants( std::pair<int32, vector<DialogParticipant>> get_channel_participants(
ChannelId channel_id, const tl_object_ptr<td_api::SupergroupMembersFilter> &filter, ChannelId channel_id, const tl_object_ptr<td_api::SupergroupMembersFilter> &filter,
const string &additional_query, int32 offset, int32 limit, int32 additional_limit, int64 &random_id, bool force, const string &additional_query, int32 offset, int32 limit, int32 additional_limit, int64 &random_id,
Promise<Unit> &&promise); bool without_bot_info, bool force, Promise<Unit> &&promise);
void send_get_channel_participants_query(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, void send_get_channel_participants_query(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset,
int32 limit, int64 random_id, Promise<Unit> &&promise); int32 limit, int64 random_id, Promise<Unit> &&promise);

View File

@ -30478,8 +30478,8 @@ std::pair<int32, vector<DialogParticipant>> MessagesManager::search_private_chat
} }
std::pair<int32, vector<DialogParticipant>> MessagesManager::search_dialog_participants( std::pair<int32, vector<DialogParticipant>> MessagesManager::search_dialog_participants(
DialogId dialog_id, const string &query, int32 limit, DialogParticipantsFilter filter, int64 &random_id, bool force, DialogId dialog_id, const string &query, int32 limit, DialogParticipantsFilter filter, int64 &random_id,
Promise<Unit> &&promise) { bool without_bot_info, bool force, Promise<Unit> &&promise) {
LOG(INFO) << "Receive searchChatMembers request to search for " << query << " in " << dialog_id; LOG(INFO) << "Receive searchChatMembers request to search for " << query << " in " << dialog_id;
if (!have_dialog_force(dialog_id)) { if (!have_dialog_force(dialog_id)) {
promise.set_error(Status::Error(3, "Chat not found")); promise.set_error(Status::Error(3, "Chat not found"));
@ -30548,7 +30548,7 @@ std::pair<int32, vector<DialogParticipant>> MessagesManager::search_dialog_parti
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(), request_filter,
additional_query, 0, limit, additional_limit, random_id, additional_query, 0, limit, additional_limit, random_id,
force, std::move(promise)); without_bot_info, force, std::move(promise));
} }
case DialogType::SecretChat: { case DialogType::SecretChat: {
promise.set_value(Unit()); promise.set_value(Unit());

View File

@ -534,8 +534,8 @@ class MessagesManager : public Actor {
std::pair<int32, vector<DialogParticipant>> search_dialog_participants(DialogId dialog_id, const string &query, std::pair<int32, vector<DialogParticipant>> search_dialog_participants(DialogId dialog_id, const string &query,
int32 limit, DialogParticipantsFilter filter, int32 limit, DialogParticipantsFilter filter,
int64 &random_id, bool force, int64 &random_id, bool without_bot_info,
Promise<Unit> &&promise); 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);

View File

@ -1970,7 +1970,7 @@ class SearchChatMembersRequest : public RequestActor<> {
void do_run(Promise<Unit> &&promise) override { void do_run(Promise<Unit> &&promise) override {
participants_ = td->messages_manager_->search_dialog_participants(dialog_id_, query_, limit_, filter_, random_id_, participants_ = td->messages_manager_->search_dialog_participants(dialog_id_, query_, limit_, filter_, random_id_,
get_tries() < 3, std::move(promise)); false, get_tries() < 3, std::move(promise));
} }
void do_send_result() override { void do_send_result() override {
@ -2286,8 +2286,8 @@ class GetSupergroupMembersRequest : public RequestActor<> {
std::pair<int32, vector<DialogParticipant>> participants_; std::pair<int32, vector<DialogParticipant>> participants_;
void do_run(Promise<Unit> &&promise) override { void do_run(Promise<Unit> &&promise) override {
participants_ = td->contacts_manager_->get_channel_participants(channel_id_, filter_, string(), offset_, limit_, -1, participants_ = td->contacts_manager_->get_channel_participants(
random_id_, get_tries() < 3, std::move(promise)); channel_id_, filter_, string(), offset_, limit_, -1, random_id_, false, get_tries() < 3, std::move(promise));
} }
void do_send_result() override { void do_send_result() override {