diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index e16c5fbf1..a1eae2790 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -809,14 +809,14 @@ starSubscriptionPricing period:int32 star_count:int53 = StarSubscriptionPricing; //@expiration_date Point in time (Unix timestamp) when the subscription will expire or expired //@can_reuse True, if the subscription is active and the user can use the method reuseStarSubscription to join the subscribed chat again //@is_canceled True, if the subscription was canceled -//@is_expiring True, if the subscription expires soon and there are no enough Telegram Stars on the user's balance to prolongate it +//@is_expiring True, if the subscription expires soon and there are no enough Telegram Stars on the user's balance to extend it //@pricing The subscription plan starSubscription id:string chat_id:int53 expiration_date:int32 can_reuse:Bool is_canceled:Bool is_expiring:Bool pricing:starSubscriptionPricing = StarSubscription; //@description Represents a list of Telegram Star subscriptions //@star_count The amount of owned Telegram Stars //@subscriptions List of subbscriptions for Telegram Stars -//@required_star_count The number of Telegram Stars required to buy to prolongate subscriptions expiring soon +//@required_star_count The number of Telegram Stars required to buy to extend subscriptions expiring soon //@next_offset The offset for the next request. If empty, then there are no more results starSubscriptions star_count:int53 subscriptions:vector required_star_count:int53 next_offset:string = StarSubscriptions; @@ -11485,9 +11485,9 @@ getStarGiftPaymentOptions user_id:int53 = StarPaymentOptions; getStarTransactions owner_id:MessageSender subscription_id:string direction:StarTransactionDirection offset:string limit:int32 = StarTransactions; //@description Returns the list of Telegram Star subscriptions for the current user +//@only_expiring Pass true to receive only expiring subscriptions for which there are no enough Telegram Stars to extend //@offset Offset of the first subscription to return as received from the previous request; use empty string to get the first chunk of results -//@limit The maximum number of results to return -getStarSubscriptions offset:string limit:int32 = StarSubscriptions; +getStarSubscriptions only_expiring:Bool offset:string = StarSubscriptions; //@description Checks whether an in-store purchase is possible. Must be called before any in-store purchase @purpose Transaction purpose canPurchaseFromStore purpose:StorePaymentPurpose = Ok; diff --git a/td/telegram/StarManager.cpp b/td/telegram/StarManager.cpp index 92a770a30..c2b6057a6 100644 --- a/td/telegram/StarManager.cpp +++ b/td/telegram/StarManager.cpp @@ -391,8 +391,11 @@ class GetStarsSubscriptionsQuery final : public Td::ResultHandler { : promise_(std::move(promise)) { } - void send(const string &offset, int32 limit) { + void send(bool only_expiring, const string &offset) { int32 flags = 0; + if (only_expiring) { + flags |= telegram_api::payments_getStarsSubscriptions::MISSING_BALANCE_MASK; + } send_query(G()->net_query_creator().create(telegram_api::payments_getStarsSubscriptions( flags, false /*ignored*/, telegram_api::make_object(), offset))); } @@ -719,12 +722,9 @@ void StarManager::do_get_star_transactions(DialogId dialog_id, const string &sub ->send(dialog_id, subscription_id, offset, limit, std::move(direction)); } -void StarManager::get_star_subscriptions(const string &offset, int32 limit, +void StarManager::get_star_subscriptions(bool only_expiring, const string &offset, Promise> &&promise) { - if (limit < 0) { - return promise.set_error(Status::Error(400, "Limit must be non-negative")); - } - td_->create_handler(std::move(promise))->send(offset, limit); + td_->create_handler(std::move(promise))->send(only_expiring, offset); } void StarManager::edit_star_subscriptions(const string &subscription_id, bool is_canceled, Promise &&promise) { diff --git a/td/telegram/StarManager.h b/td/telegram/StarManager.h index e0ac4c20f..4c4356e72 100644 --- a/td/telegram/StarManager.h +++ b/td/telegram/StarManager.h @@ -36,7 +36,7 @@ class StarManager final : public Actor { td_api::object_ptr &&direction, Promise> &&promise); - void get_star_subscriptions(const string &offset, int32 limit, + void get_star_subscriptions(bool only_expiring, const string &offset, Promise> &&promise); void edit_star_subscriptions(const string &subscription_id, bool is_canceled, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 9eb33f527..b17383c0f 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -9131,7 +9131,7 @@ void Td::on_request(uint64 id, td_api::getStarSubscriptions &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.offset_); CREATE_REQUEST_PROMISE(); - star_manager_->get_star_subscriptions(request.offset_, request.limit_, std::move(promise)); + star_manager_->get_star_subscriptions(request.only_expiring_, request.offset_, std::move(promise)); } void Td::on_request(uint64 id, td_api::editStarSubscription &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 6fe4ec31d..85eea544a 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3478,10 +3478,10 @@ class CliClient final : public Actor { send_request(td_api::make_object(as_message_sender(owner_id), subscription_id, std::move(direction), offset, as_limit(limit))); } else if (op == "gssu") { + bool only_expiring; string offset; - string limit; - get_args(args, offset, limit); - send_request(td_api::make_object(offset, as_limit(limit))); + get_args(args, only_expiring, offset); + send_request(td_api::make_object(only_expiring, offset)); } else if (op == "ess") { string subscription_id; bool is_canceled;