Add getStarTransactions.subscription_id.
This commit is contained in:
parent
2c8a304e5a
commit
191a742fa2
@ -11476,10 +11476,11 @@ getStarGiftPaymentOptions user_id:int53 = StarPaymentOptions;
|
||||
//@description Returns the list of Telegram Star transactions for the specified owner
|
||||
//@owner_id Identifier of the owner of the Telegram Stars; can be the identifier of the current user, identifier of an owned bot,
|
||||
//-or identifier of a channel chat with supergroupFullInfo.can_get_star_revenue_statistics == true
|
||||
//@subscription_id If non-empty, only transactions related to the Star Subscription will be returned
|
||||
//@direction Direction of the transactions to receive; pass null to get all transactions
|
||||
//@offset Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of results
|
||||
//@limit The maximum number of transactions to return
|
||||
getStarTransactions owner_id:MessageSender direction:StarTransactionDirection offset:string limit:int32 = StarTransactions;
|
||||
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
|
||||
//@offset Offset of the first subscription to return as received from the previous request; use empty string to get the first chunk of results
|
||||
|
@ -122,7 +122,7 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, const string &offset, int32 limit,
|
||||
void send(DialogId dialog_id, const string &subscription_id, const string &offset, int32 limit,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||
@ -130,6 +130,9 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(400, "Have no access to the chat"));
|
||||
}
|
||||
int32 flags = 0;
|
||||
if (!subscription_id.empty()) {
|
||||
flags |= telegram_api::payments_getStarsTransactions::SUBSCRIPTION_ID_MASK;
|
||||
}
|
||||
if (direction != nullptr) {
|
||||
switch (direction->get_id()) {
|
||||
case td_api::starTransactionDirectionIncoming::ID:
|
||||
@ -147,7 +150,7 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::payments_getStarsTransactions(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
string(), std::move(input_peer), offset, limit)));
|
||||
subscription_id, std::move(input_peer), offset, limit)));
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, const string &transaction_id, bool is_refund) {
|
||||
@ -684,34 +687,36 @@ void StarManager::get_star_gift_payment_options(UserId user_id,
|
||||
td_->create_handler<GetStarsGiftOptionsQuery>(std::move(promise))->send(std::move(input_user));
|
||||
}
|
||||
|
||||
void StarManager::get_star_transactions(td_api::object_ptr<td_api::MessageSender> owner_id, const string &offset,
|
||||
int32 limit, td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
void StarManager::get_star_transactions(td_api::object_ptr<td_api::MessageSender> owner_id,
|
||||
const string &subscription_id, const string &offset, int32 limit,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, dialog_id, get_message_sender_dialog_id(td_, owner_id, true, false));
|
||||
TRY_STATUS_PROMISE(promise, can_manage_stars(dialog_id, true));
|
||||
if (limit < 0) {
|
||||
return promise.set_error(Status::Error(400, "Limit must be non-negative"));
|
||||
}
|
||||
td_->stickers_manager_->load_premium_gift_sticker_set(
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), dialog_id, offset, limit, direction = std::move(direction),
|
||||
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||
td_->stickers_manager_->load_premium_gift_sticker_set(PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this), dialog_id, subscription_id, offset, limit, direction = std::move(direction),
|
||||
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
send_closure(actor_id, &StarManager::do_get_star_transactions, dialog_id, offset, limit, std::move(direction),
|
||||
std::move(promise));
|
||||
send_closure(actor_id, &StarManager::do_get_star_transactions, dialog_id, subscription_id, offset, limit,
|
||||
std::move(direction), std::move(promise));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void StarManager::do_get_star_transactions(DialogId dialog_id, const string &offset, int32 limit,
|
||||
void StarManager::do_get_star_transactions(DialogId dialog_id, const string &subscription_id, const string &offset,
|
||||
int32 limit,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
TRY_STATUS_PROMISE(promise, can_manage_stars(dialog_id, true));
|
||||
|
||||
td_->create_handler<GetStarsTransactionsQuery>(std::move(promise))
|
||||
->send(dialog_id, offset, limit, std::move(direction));
|
||||
->send(dialog_id, subscription_id, offset, limit, std::move(direction));
|
||||
}
|
||||
|
||||
void StarManager::get_star_subscriptions(const string &offset, int32 limit,
|
||||
|
@ -31,7 +31,8 @@ class StarManager final : public Actor {
|
||||
|
||||
void get_star_gift_payment_options(UserId user_id, Promise<td_api::object_ptr<td_api::starPaymentOptions>> &&promise);
|
||||
|
||||
void get_star_transactions(td_api::object_ptr<td_api::MessageSender> owner_id, const string &offset, int32 limit,
|
||||
void get_star_transactions(td_api::object_ptr<td_api::MessageSender> owner_id, const string &subscription_id,
|
||||
const string &offset, int32 limit,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise);
|
||||
|
||||
@ -68,7 +69,7 @@ class StarManager final : public Actor {
|
||||
|
||||
Status can_manage_stars(DialogId dialog_id, bool allow_self = false) const;
|
||||
|
||||
void do_get_star_transactions(DialogId dialog_id, const string &offset, int32 limit,
|
||||
void do_get_star_transactions(DialogId dialog_id, const string &subscription_id, const string &offset, int32 limit,
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
||||
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise);
|
||||
|
||||
|
@ -9120,10 +9120,11 @@ void Td::on_request(uint64 id, const td_api::getStarGiftPaymentOptions &request)
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getStarTransactions &request) {
|
||||
CLEAN_INPUT_STRING(request.subscription_id_);
|
||||
CLEAN_INPUT_STRING(request.offset_);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
star_manager_->get_star_transactions(std::move(request.owner_id_), request.offset_, request.limit_,
|
||||
std::move(request.direction_), std::move(promise));
|
||||
star_manager_->get_star_transactions(std::move(request.owner_id_), request.subscription_id_, request.offset_,
|
||||
request.limit_, std::move(request.direction_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getStarSubscriptions &request) {
|
||||
|
@ -3465,17 +3465,18 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getStarGiftPaymentOptions>(user_id));
|
||||
} else if (op == "gsta" || op == "gsti" || op == "gsto") {
|
||||
string owner_id;
|
||||
string subscription_id;
|
||||
string offset;
|
||||
string limit;
|
||||
get_args(args, owner_id, offset, limit);
|
||||
get_args(args, owner_id, subscription_id, offset, limit);
|
||||
td_api::object_ptr<td_api::StarTransactionDirection> direction;
|
||||
if (op == "gsti") {
|
||||
direction = td_api::make_object<td_api::starTransactionDirectionIncoming>();
|
||||
} else if (op == "gsto") {
|
||||
direction = td_api::make_object<td_api::starTransactionDirectionOutgoing>();
|
||||
}
|
||||
send_request(td_api::make_object<td_api::getStarTransactions>(as_message_sender(owner_id), std::move(direction),
|
||||
offset, as_limit(limit)));
|
||||
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") {
|
||||
string offset;
|
||||
string limit;
|
||||
|
Loading…
Reference in New Issue
Block a user