Add td_api::channelTransactionPurposeJoin.

This commit is contained in:
levlam 2024-07-25 18:23:24 +03:00
parent 83be2c698c
commit 9315b118e0
2 changed files with 31 additions and 6 deletions

View File

@ -870,6 +870,18 @@ starTransactionDirectionIncoming = StarTransactionDirection;
starTransactionDirectionOutgoing = StarTransactionDirection; starTransactionDirectionOutgoing = StarTransactionDirection;
//@class ChannelTransactionPurpose @description Describes purpose of a transaction with a channel
//@description Paid media were bought
//@message_id Identifier of the corresponding message with paid media; can be an identifier of a deleted message
//@media The bought media if they are still accessible
channelTransactionPurposePaidMedia message_id:int53 media:vector<PaidMedia> = ChannelTransactionPurpose;
//@description User joined the channel and subscribed to regular payments in Telegram Stars
//@period The number of seconds between consecutive Telegram Star debiting
channelTransactionPurposeJoin period:int32 = ChannelTransactionPurpose;
//@class StarTransactionPartner @description Describes source or recipient of a transaction with Telegram Stars //@class StarTransactionPartner @description Describes source or recipient of a transaction with Telegram Stars
//@description The transaction is a transaction with Telegram through a bot //@description The transaction is a transaction with Telegram through a bot
@ -893,11 +905,10 @@ starTransactionPartnerTelegramAds = StarTransactionPartner;
//@invoice_payload Invoice payload; for bots only //@invoice_payload Invoice payload; for bots only
starTransactionPartnerBot user_id:int53 product_info:productInfo invoice_payload:bytes = StarTransactionPartner; starTransactionPartnerBot user_id:int53 product_info:productInfo invoice_payload:bytes = StarTransactionPartner;
//@description The transaction is a transaction with a channel chat //@description The transaction is a transaction with a channel
//@chat_id Identifier of the chat //@chat_id Identifier of the chat
//@paid_media_message_id Identifier of the corresponding message with paid media; can be an identifier of a deleted message //@purpose Purpose of the transaction
//@media Information about the bought media starTransactionPartnerChannel chat_id:int53 purpose:ChannelTransactionPurpose = StarTransactionPartner;
starTransactionPartnerChannel chat_id:int53 paid_media_message_id:int53 media:vector<PaidMedia> = StarTransactionPartner;
//@description The transaction is a gift of Telegram Stars from another user //@description The transaction is a gift of Telegram Stars from another user
//@user_id Identifier of the user; 0 if the gift was anonymous //@user_id Identifier of the user; 0 if the gift was anonymous
@ -5715,7 +5726,7 @@ telegramPaymentPurposeStars currency:string amount:int53 star_count:int53 = Tele
//@star_count Number of bought Telegram Stars //@star_count Number of bought Telegram Stars
telegramPaymentPurposeGiftedStars user_id:int53 currency:string amount:int53 star_count:int53 = TelegramPaymentPurpose; telegramPaymentPurposeGiftedStars user_id:int53 currency:string amount:int53 star_count:int53 = TelegramPaymentPurpose;
//@description The user joins a chat and subscribes to regular Payments in Telegram Stars @invite_link Invite link to use //@description The user joins a chat and subscribes to regular payments in Telegram Stars @invite_link Invite link to use
telegramPaymentPurposeJoinChat invite_link:string = TelegramPaymentPurpose; telegramPaymentPurposeJoinChat invite_link:string = TelegramPaymentPurpose;

View File

@ -273,6 +273,16 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
bot_payload); bot_payload);
} }
if (td_->dialog_manager_->is_broadcast_channel(dialog_id)) { if (td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
if (transaction->subscription_period_ > 0) {
SCOPE_EXIT {
transaction->subscription_period_ = 0;
};
td_->dialog_manager_->force_create_dialog(dialog_id, "starsTransactionPeer", true);
return td_api::make_object<td_api::starTransactionPartnerChannel>(
td_->dialog_manager_->get_chat_id_object(dialog_id, "starTransactionPartnerChannel"),
td_api::make_object<td_api::channelTransactionPurposeJoin>(transaction->subscription_period_));
}
SCOPE_EXIT { SCOPE_EXIT {
transaction->msg_id_ = 0; transaction->msg_id_ = 0;
transaction->extended_media_.clear(); transaction->extended_media_.clear();
@ -295,7 +305,8 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
td_->dialog_manager_->force_create_dialog(dialog_id, "starsTransactionPeer", true); td_->dialog_manager_->force_create_dialog(dialog_id, "starsTransactionPeer", true);
return td_api::make_object<td_api::starTransactionPartnerChannel>( return td_api::make_object<td_api::starTransactionPartnerChannel>(
td_->dialog_manager_->get_chat_id_object(dialog_id, "starTransactionPartnerChannel"), td_->dialog_manager_->get_chat_id_object(dialog_id, "starTransactionPartnerChannel"),
message_id.get(), std::move(extended_media_objects)); td_api::make_object<td_api::channelTransactionPurposePaidMedia>(message_id.get(),
std::move(extended_media_objects)));
} }
LOG(ERROR) << "Receive Telegram Star transaction with " << dialog_id; LOG(ERROR) << "Receive Telegram Star transaction with " << dialog_id;
return td_api::make_object<td_api::starTransactionPartnerUnsupported>(); return td_api::make_object<td_api::starTransactionPartnerUnsupported>();
@ -326,6 +337,9 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
if (transaction->gift_) { if (transaction->gift_) {
LOG(ERROR) << "Receive gift with " << to_string(star_transaction); LOG(ERROR) << "Receive gift with " << to_string(star_transaction);
} }
if (transaction->subscription_period_ != 0) {
LOG(ERROR) << "Receive subscription period with " << to_string(star_transaction);
}
} }
if (!file_ids.empty()) { if (!file_ids.empty()) {
auto file_source_id = auto file_source_id =