From ac64cf9b457b247a6a3323fbc42e64fc61b1c952 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 20 Oct 2023 15:28:59 +0300 Subject: [PATCH] Add getChatBoosts.only_gift_codes. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/BoostManager.cpp | 10 +++++++--- td/telegram/BoostManager.h | 2 +- td/telegram/Td.cpp | 3 ++- td/telegram/cli.cpp | 5 +++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a0c207a3c..f41db4b6d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -7933,9 +7933,10 @@ getChatBoostLinkInfo url:string = ChatBoostLinkInfo; //@description Returns list of boosts applied to a chat. The user must be an administrator in the channel chat to get the list of boosts //@chat_id Identifier of the chat +//@only_gift_codes Pass true to receive only boosts received from gift codes and giveaways created by the chat //@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results //@limit The maximum number of boosts to be returned; up to 100. For optimal performance, the number of returned boosts can be smaller than the specified limit -getChatBoosts chat_id:int53 offset:string limit:int32 = FoundChatBoosts; +getChatBoosts chat_id:int53 only_gift_codes:Bool offset:string limit:int32 = FoundChatBoosts; //@description Returns information about a bot that can be added to attachment or side menu @bot_user_id Bot's user identifier diff --git a/td/telegram/BoostManager.cpp b/td/telegram/BoostManager.cpp index 75d2de2a5..3bf24cdd4 100644 --- a/td/telegram/BoostManager.cpp +++ b/td/telegram/BoostManager.cpp @@ -127,10 +127,14 @@ class GetBoostsListQuery final : public Td::ResultHandler { : promise_(std::move(promise)) { } - void send(DialogId dialog_id, const string &offset, int32 limit) { + void send(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit) { dialog_id_ = dialog_id; auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); CHECK(input_peer != nullptr); + int32 flags = 0; + if (only_gift_codes) { + flags |= telegram_api::premium_getBoostsList::GIFTS_MASK; + } send_query(G()->net_query_creator().create( telegram_api::premium_getBoostsList(0, false /*ignored*/, std::move(input_peer), offset, limit))); } @@ -279,7 +283,7 @@ td_api::object_ptr BoostManager::get_chat_boost_link_ is_public, td_->messages_manager_->get_chat_id_object(dialog_id, "chatBoostLinkInfo")); } -void BoostManager::get_dialog_boosts(DialogId dialog_id, const string &offset, int32 limit, +void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit, Promise> &&promise) { if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -291,7 +295,7 @@ void BoostManager::get_dialog_boosts(DialogId dialog_id, const string &offset, i return promise.set_error(Status::Error(400, "Parameter limit must be positive")); } - td_->create_handler(std::move(promise))->send(dialog_id, offset, limit); + td_->create_handler(std::move(promise))->send(dialog_id, only_gift_codes, offset, limit); } } // namespace td diff --git a/td/telegram/BoostManager.h b/td/telegram/BoostManager.h index 691ebcee1..9f02e5e5d 100644 --- a/td/telegram/BoostManager.h +++ b/td/telegram/BoostManager.h @@ -34,7 +34,7 @@ class BoostManager final : public Actor { td_api::object_ptr get_chat_boost_link_info_object(const DialogBoostLinkInfo &info) const; - void get_dialog_boosts(DialogId dialog_id, const string &offset, int32 limit, + void get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit, Promise> &&promise); private: diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 8687f507a..853caada8 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6668,7 +6668,8 @@ void Td::on_request(uint64 id, td_api::getChatBoosts &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.offset_); CREATE_REQUEST_PROMISE(); - boost_manager_->get_dialog_boosts(DialogId(request.chat_id_), request.offset_, request.limit_, std::move(promise)); + boost_manager_->get_dialog_boosts(DialogId(request.chat_id_), request.only_gift_codes_, request.offset_, + request.limit_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 4e0e313a0..cd66cfcf3 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -4383,10 +4383,11 @@ class CliClient final : public Actor { send_request(td_api::make_object(args)); } else if (op == "gcb") { ChatId chat_id; + bool only_gift_codes; string offset; string limit; - get_args(args, chat_id); - send_request(td_api::make_object(chat_id, offset, as_limit(limit))); + get_args(args, chat_id, only_gift_codes, offset, limit); + send_request(td_api::make_object(chat_id, only_gift_codes, offset, as_limit(limit))); } else if (op == "gamb") { UserId user_id; get_args(args, user_id);