diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 713a52ad1..074b7a6b9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -353,9 +353,6 @@ botCommand command:string description:string = BotCommand; //@description Contains a list of bot commands @bot_user_id Bot's user identifier @commands List of bot commands botCommands bot_user_id:int32 commands:vector = BotCommands; -//@description Provides information about a bot and its supported commands @commands A list of commands supported by the bot -botInfo commands:vector = BotInfo; - //@description Represents a location to which a chat is connected @location The location @address Location address; 1-64 characters, as defined by the chat owner chatLocation location:location address:string = ChatLocation; @@ -497,8 +494,7 @@ chatMemberStatusBanned banned_until_date:int32 = ChatMemberStatus; //@inviter_user_id Identifier of a user that invited/promoted/banned this member in the chat; 0 if unknown //@joined_chat_date Point in time (Unix timestamp) when the user joined the chat //@status Status of the member in the chat -//@bot_info If the user is a bot, information about the bot; may be null. Can be null even for a bot if the bot is not the chat member -chatMember member_id:MessageSender inviter_user_id:int32 joined_chat_date:int32 status:ChatMemberStatus bot_info:botInfo = ChatMember; +chatMember member_id:MessageSender inviter_user_id:int32 joined_chat_date:int32 status:ChatMemberStatus = ChatMember; //@description Contains a list of chat members @total_count Approximate total count of chat members found @members A list of chat members chatMembers total_count:int32 members:vector = ChatMembers; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 61541057c..2d0393b5a 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -11780,8 +11780,7 @@ tl_object_ptr ContactsManager::get_chat_member_object( return td_api::make_object( td_->messages_manager_->get_message_sender_object_const(dialog_id), get_user_id_object(dialog_participant.inviter_user_id, "chatMember.inviter_user_id"), - dialog_participant.joined_date, dialog_participant.status.get_chat_member_status_object(), - get_bot_info_object(participant_user_id)); + dialog_participant.joined_date, dialog_participant.status.get_chat_member_status_object()); } bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &status, const string &source) { @@ -15002,7 +15001,7 @@ DialogParticipants ContactsManager::search_private_chat_participants(UserId my_u } void ContactsManager::search_dialog_participants(DialogId dialog_id, const string &query, int32 limit, - DialogParticipantsFilter filter, bool without_bot_info, + DialogParticipantsFilter filter, Promise &&promise) { LOG(INFO) << "Receive searchChatMembers request to search for \"" << query << "\" in " << dialog_id << " with filter " << filter; @@ -15068,8 +15067,7 @@ void ContactsManager::search_dialog_participants(DialogId dialog_id, const strin } return get_channel_participants(dialog_id.get_channel_id(), std::move(request_filter), - std::move(additional_query), 0, limit, additional_limit, without_bot_info, - std::move(promise)); + std::move(additional_query), 0, limit, additional_limit, std::move(promise)); } case DialogType::SecretChat: { auto peer_user_id = get_secret_chat_user_id(dialog_id.get_secret_chat_id()); @@ -15196,21 +15194,6 @@ DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id, } } - if (!td_->auth_manager_->is_bot() && participant_dialog_id.get_type() == DialogType::User && - is_user_bot(participant_dialog_id.get_user_id())) { - auto user_id = participant_dialog_id.get_user_id(); - auto u = get_user(user_id); - CHECK(u != nullptr); - if (is_bot_info_expired(user_id, u->bot_info_version)) { - if (force) { - LOG(ERROR) << "Can't find cached BotInfo"; - } else { - send_get_user_full_query(user_id, get_input_user(user_id), std::move(promise), "get_channel_participant"); - return DialogParticipant(); - } - } - } - do { random_id = Random::secure_int64(); } while (random_id == 0 || received_channel_participant_.find(random_id) != received_channel_participant_.end()); @@ -15258,8 +15241,7 @@ void ContactsManager::on_get_channel_participant(ChannelId channel_id, int64 ran void ContactsManager::get_channel_participants(ChannelId channel_id, tl_object_ptr &&filter, string additional_query, int32 offset, int32 limit, - int32 additional_limit, bool without_bot_info, - Promise &&promise) { + int32 additional_limit, Promise &&promise) { if (limit <= 0) { return promise.set_error(Status::Error(400, "Parameter limit must be positive")); } @@ -15271,43 +15253,15 @@ void ContactsManager::get_channel_participants(ChannelId channel_id, return promise.set_error(Status::Error(400, "Parameter offset must be non-negative")); } - auto load_channel_full_promise = - PromiseCreator::lambda([actor_id = actor_id(this), channel_id, filter = ChannelParticipantsFilter(filter), - additional_query = std::move(additional_query), offset, limit, additional_limit, - promise = std::move(promise)](Result &&result) mutable { - if (result.is_error()) { - promise.set_error(result.move_as_error()); - } else { - send_closure(actor_id, &ContactsManager::do_get_channel_participants, channel_id, std::move(filter), - std::move(additional_query), offset, limit, additional_limit, std::move(promise)); - } - }); - 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()); -} - -void ContactsManager::do_get_channel_participants(ChannelId channel_id, ChannelParticipantsFilter &&filter, - string additional_query, int32 offset, int32 limit, - int32 additional_limit, Promise &&promise) { - if (G()->close_flag()) { - return promise.set_error(Status::Error(500, "Request aborted")); - } - 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")); } + ChannelParticipantsFilter participants_filter(filter); 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)]( + [actor_id = actor_id(this), channel_id, filter = participants_filter, + additional_query = std::move(additional_query), offset, limit, additional_limit, promise = std::move(promise)]( Result> &&result) mutable { if (result.is_error()) { promise.set_error(result.move_as_error()); @@ -15317,7 +15271,7 @@ void ContactsManager::do_get_channel_participants(ChannelId channel_id, ChannelP } }); td_->create_handler(std::move(get_channel_participants_promise)) - ->send(channel_id, std::move(filter), offset, limit); + ->send(channel_id, std::move(participants_filter), offset, limit); } vector ContactsManager::get_dialog_administrators(DialogId dialog_id, int left_tries, @@ -16256,18 +16210,6 @@ tl_object_ptr ContactsManager::get_secret_chat_object_const( secret_chat->is_outbound, secret_chat->key_hash, secret_chat->layer); } -td_api::object_ptr ContactsManager::get_bot_info_object(UserId user_id) const { - auto bot_info = get_bot_info(user_id); - if (bot_info == nullptr) { - return nullptr; - } - - auto commands = transform(bot_info->commands, [](auto &command) { - return td_api::make_object(command.first, command.second); - }); - return td_api::make_object(std::move(commands)); -} - tl_object_ptr ContactsManager::get_chat_invite_link_info_object( const string &invite_link) const { auto it = invite_link_infos_.find(invite_link); diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 2867bd0b0..b0512fe86 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -529,13 +529,13 @@ class ContactsManager : public Actor { bool force, Promise &&promise); void search_dialog_participants(DialogId dialog_id, const string &query, int32 limit, DialogParticipantsFilter filter, - bool without_bot_info, Promise &&promise); + Promise &&promise); vector get_dialog_administrators(DialogId dialog_id, int left_tries, Promise &&promise); void get_channel_participants(ChannelId channel_id, tl_object_ptr &&filter, string additional_query, int32 offset, int32 limit, int32 additional_limit, - bool without_bot_info, Promise &&promise); + Promise &&promise); int32 get_user_id_object(UserId user_id, const char *source) const; @@ -1462,8 +1462,6 @@ class ContactsManager : public Actor { td_api::object_ptr get_user_status_object(UserId user_id, const User *u) const; - td_api::object_ptr get_bot_info_object(UserId user_id) const; - tl_object_ptr get_user_object(UserId user_id, const User *u) const; tl_object_ptr get_user_full_info_object(UserId user_id, const UserFull *user_full) const; @@ -1515,10 +1513,6 @@ class ContactsManager : public Actor { void do_search_chat_participants(ChatId chat_id, const string &query, int32 limit, DialogParticipantsFilter filter, Promise &&promise); - void do_get_channel_participants(ChannelId channel_id, ChannelParticipantsFilter &&filter, string additional_query, - int32 offset, int32 limit, int32 additional_limit, - Promise &&promise); - void on_get_channel_participants(ChannelId channel_id, ChannelParticipantsFilter filter, int32 offset, int32 limit, string additional_query, int32 additional_limit, tl_object_ptr &&channel_participants, diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 159b996e9..421435aa1 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -2591,7 +2591,7 @@ void GroupCallManager::try_load_group_call_administrators(InputGroupCallId input std::move(result)); }); td_->contacts_manager_->search_dialog_participants( - dialog_id, string(), 100, DialogParticipantsFilter(DialogParticipantsFilter::Type::Administrators), true, + dialog_id, string(), 100, DialogParticipantsFilter(DialogParticipantsFilter::Type::Administrators), std::move(promise)); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 42617b6b9..f641d1f93 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11846,7 +11846,7 @@ void MessagesManager::on_update_dialog_online_member_count_timeout(DialogId dial } else { td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(), td_api::make_object(), - string(), 0, 200, 200, true, Auto()); + string(), 0, 200, 200, Auto()); } return; } @@ -19463,7 +19463,7 @@ void MessagesManager::open_dialog(Dialog *d) { if (participant_count < 195) { // include unknown participant_count td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(), td_api::make_object(), - string(), 0, 200, 200, true, Auto()); + string(), 0, 200, 200, Auto()); } } get_channel_difference(dialog_id, d->pts, true, "open_dialog"); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 27c34c404..bc463786b 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6477,7 +6477,7 @@ void Td::on_request(uint64 id, td_api::searchChatMembers &request) { } }); contacts_manager_->search_dialog_participants(DialogId(request.chat_id_), request.query_, request.limit_, - get_dialog_participants_filter(request.filter_), false, + get_dialog_participants_filter(request.filter_), std::move(query_promise)); } @@ -6957,7 +6957,7 @@ void Td::on_request(uint64 id, td_api::getSupergroupMembers &request) { } }); contacts_manager_->get_channel_participants(ChannelId(request.supergroup_id_), std::move(request.filter_), string(), - request.offset_, request.limit_, -1, false, std::move(query_promise)); + request.offset_, request.limit_, -1, std::move(query_promise)); } void Td::on_request(uint64 id, td_api::closeSecretChat &request) {