Improve getStarWithdrawalUrl.

This commit is contained in:
levlam 2024-06-14 15:18:35 +03:00
parent 9288aa5f16
commit ebe83764eb
5 changed files with 13 additions and 12 deletions

View File

@ -10705,11 +10705,11 @@ getChatRevenueWithdrawalUrl chat_id:int53 password:string = HttpUrl;
getChatRevenueTransactions chat_id:int53 offset:int32 limit:int32 = ChatRevenueTransactions; getChatRevenueTransactions chat_id:int53 offset:int32 limit:int32 = ChatRevenueTransactions;
//@description Returns URL for Telegram star withdrawal from a bot or a chat; requires owner privileges for the bot or in the chat //@description Returns URL for Telegram star withdrawal
//@chat_id Chat identifier //@owner_id Identifier of the owner of the Telegram stars; can be identifier of an owned bot, or identifier of a channel chat with supergroupFullInfo.can_get_revenue_statistics == true
//@star_count The number of Telegram stars to withdraw //@star_count The number of Telegram stars to withdraw
//@password The 2-step verification password of the current user //@password The 2-step verification password of the current user
getStarWithdrawalUrl chat_id:int53 star_count:int53 password:string = HttpUrl; getStarWithdrawalUrl owner_id:MessageSender star_count:int53 password:string = HttpUrl;
//@description Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true @chat_id Chat identifier @is_dark Pass true if a dark theme is used by the application //@description Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true @chat_id Chat identifier @is_dark Pass true if a dark theme is used by the application

View File

@ -286,10 +286,9 @@ void StarManager::refund_star_payment(UserId user_id, const string &telegram_pay
->send(std::move(input_user), telegram_payment_charge_id); ->send(std::move(input_user), telegram_payment_charge_id);
} }
void StarManager::get_star_withdrawal_url(DialogId dialog_id, int64 star_count, const string &password, void StarManager::get_star_withdrawal_url(const td_api::object_ptr<td_api::MessageSender> &owner_id, int64 star_count,
Promise<string> &&promise) { const string &password, Promise<string> &&promise) {
TRY_STATUS_PROMISE(promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write, TRY_RESULT_PROMISE(promise, dialog_id, get_message_sender_dialog_id(td_, owner_id, true, false));
"get_star_withdrawal_url"));
TRY_STATUS_PROMISE(promise, can_manage_stars(dialog_id)); TRY_STATUS_PROMISE(promise, can_manage_stars(dialog_id));
if (password.empty()) { if (password.empty()) {
return promise.set_error(Status::Error(400, "PASSWORD_HASH_INVALID")); return promise.set_error(Status::Error(400, "PASSWORD_HASH_INVALID"));

View File

@ -32,7 +32,8 @@ class StarManager final : public Actor {
void refund_star_payment(UserId user_id, const string &telegram_payment_charge_id, Promise<Unit> &&promise); void refund_star_payment(UserId user_id, const string &telegram_payment_charge_id, Promise<Unit> &&promise);
void get_star_withdrawal_url(DialogId dialog_id, int64 star_count, const string &password, Promise<string> &&promise); void get_star_withdrawal_url(const td_api::object_ptr<td_api::MessageSender> &owner_id, int64 star_count,
const string &password, Promise<string> &&promise);
private: private:
void tear_down() final; void tear_down() final;

View File

@ -8744,7 +8744,7 @@ void Td::on_request(uint64 id, const td_api::getStarWithdrawalUrl &request) {
promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok())); promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok()));
} }
}); });
star_manager_->get_star_withdrawal_url(DialogId(request.chat_id_), request.star_count_, request.password_, star_manager_->get_star_withdrawal_url(request.owner_id_, request.star_count_, request.password_,
std::move(query_promise)); std::move(query_promise));
} }

View File

@ -6781,11 +6781,12 @@ class CliClient final : public Actor {
get_args(args, chat_id, offset, limit); get_args(args, chat_id, offset, limit);
send_request(td_api::make_object<td_api::getChatRevenueTransactions>(chat_id, offset, as_limit(limit))); send_request(td_api::make_object<td_api::getChatRevenueTransactions>(chat_id, offset, as_limit(limit)));
} else if (op == "gswu") { } else if (op == "gswu") {
ChatId chat_id; string owner_id;
int32 star_count; int32 star_count;
string password; string password;
get_args(args, chat_id, star_count, password); get_args(args, owner_id, star_count, password);
send_request(td_api::make_object<td_api::getStarWithdrawalUrl>(chat_id, star_count, password)); send_request(
td_api::make_object<td_api::getStarWithdrawalUrl>(as_message_sender(owner_id), star_count, password));
} else { } else {
op_not_found_count++; op_not_found_count++;
} }