From 9315b118e0620dd17ce331d52fd3e6b701f8d26f Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 25 Jul 2024 18:23:24 +0300 Subject: [PATCH] Add td_api::channelTransactionPurposeJoin. --- td/generate/scheme/td_api.tl | 21 ++++++++++++++++----- td/telegram/StarManager.cpp | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a8b3b4d07..3b8a164c2 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -870,6 +870,18 @@ starTransactionDirectionIncoming = 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 = 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 //@description The transaction is a transaction with Telegram through a bot @@ -893,11 +905,10 @@ starTransactionPartnerTelegramAds = StarTransactionPartner; //@invoice_payload Invoice payload; for bots only 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 -//@paid_media_message_id Identifier of the corresponding message with paid media; can be an identifier of a deleted message -//@media Information about the bought media -starTransactionPartnerChannel chat_id:int53 paid_media_message_id:int53 media:vector = StarTransactionPartner; +//@purpose Purpose of the transaction +starTransactionPartnerChannel chat_id:int53 purpose:ChannelTransactionPurpose = StarTransactionPartner; //@description The transaction is a gift of Telegram Stars from another user //@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 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; diff --git a/td/telegram/StarManager.cpp b/td/telegram/StarManager.cpp index d38e1ae9d..5373a313c 100644 --- a/td/telegram/StarManager.cpp +++ b/td/telegram/StarManager.cpp @@ -273,6 +273,16 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler { bot_payload); } 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_->dialog_manager_->get_chat_id_object(dialog_id, "starTransactionPartnerChannel"), + td_api::make_object(transaction->subscription_period_)); + } + SCOPE_EXIT { transaction->msg_id_ = 0; transaction->extended_media_.clear(); @@ -295,7 +305,8 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler { td_->dialog_manager_->force_create_dialog(dialog_id, "starsTransactionPeer", true); return td_api::make_object( td_->dialog_manager_->get_chat_id_object(dialog_id, "starTransactionPartnerChannel"), - message_id.get(), std::move(extended_media_objects)); + td_api::make_object(message_id.get(), + std::move(extended_media_objects))); } LOG(ERROR) << "Receive Telegram Star transaction with " << dialog_id; return td_api::make_object(); @@ -326,6 +337,9 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler { if (transaction->gift_) { 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()) { auto file_source_id =