Add getStarSubscriptions.only_expiring.

This commit is contained in:
levlam 2024-08-05 10:27:06 +03:00
parent 176700325e
commit aaf9d40bea
5 changed files with 15 additions and 15 deletions

View File

@ -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<starSubscription> 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;

View File

@ -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<telegram_api::inputPeerSelf>(), 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<td_api::object_ptr<td_api::starSubscriptions>> &&promise) {
if (limit < 0) {
return promise.set_error(Status::Error(400, "Limit must be non-negative"));
}
td_->create_handler<GetStarsSubscriptionsQuery>(std::move(promise))->send(offset, limit);
td_->create_handler<GetStarsSubscriptionsQuery>(std::move(promise))->send(only_expiring, offset);
}
void StarManager::edit_star_subscriptions(const string &subscription_id, bool is_canceled, Promise<Unit> &&promise) {

View File

@ -36,7 +36,7 @@ class StarManager final : public Actor {
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise);
void get_star_subscriptions(const string &offset, int32 limit,
void get_star_subscriptions(bool only_expiring, const string &offset,
Promise<td_api::object_ptr<td_api::starSubscriptions>> &&promise);
void edit_star_subscriptions(const string &subscription_id, bool is_canceled, Promise<Unit> &&promise);

View File

@ -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) {

View File

@ -3478,10 +3478,10 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getStarTransactions>(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<td_api::getStarSubscriptions>(offset, as_limit(limit)));
get_args(args, only_expiring, offset);
send_request(td_api::make_object<td_api::getStarSubscriptions>(only_expiring, offset));
} else if (op == "ess") {
string subscription_id;
bool is_canceled;