diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 820a5febe..891092474 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -843,11 +843,33 @@ starTransactionDirectionIncoming = StarTransactionDirection; starTransactionDirectionOutgoing = StarTransactionDirection; +//@class StarTransactionSource @description Describes source or recipient of a transaction with Telegram stars + +//@description The transaction is a transaction with Telegram through a bot +starTransactionSourceTelegram = StarTransactionSource; + +//@description The transaction is a transaction with App Store +starTransactionSourceAppStore = StarTransactionSource; + +//@description The transaction is a transaction with Google Play +starTransactionSourceGooglePlay = StarTransactionSource; + +//@description The transaction is a transaction with Fragment +starTransactionSourceFragment = StarTransactionSource; + +//@description The transaction is a transaction with another user @user_id Identifier of the user +starTransactionSourceUser user_id:int53 = StarTransactionSource; + +//@description The transaction is a transaction with unknown source +starTransactionSourceUnsupported = StarTransactionSource; + + //@description Represents a transaction changing the amount of owned Telegram stars //@id Unique identifier of the transaction //@star_count The amount of added owned Telegram stars; negative for outgoing transactions //@date Point in time (Unix timestamp) when the transaction was completed -starTransaction id:string star_count:int53 date:int32 = StarTransaction; +//@source Source of the transaction, or its recipient for outgoing transactions +starTransaction id:string star_count:int53 date:int32 source:StarTransactionSource = StarTransaction; //@description Represents a list of Telegram star transactions //@star_count The amount of owned Telegram stars diff --git a/td/telegram/Premium.cpp b/td/telegram/Premium.cpp index b1b594b9b..81bfcdc60 100644 --- a/td/telegram/Premium.cpp +++ b/td/telegram/Premium.cpp @@ -679,8 +679,33 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler { vector> transactions; for (auto &transaction : result->history_) { - transactions.push_back( - td_api::make_object(transaction->id_, transaction->stars_, transaction->date_)); + auto source = [&]() -> td_api::object_ptr { + switch (transaction->peer_->get_id()) { + case telegram_api::starsTransactionPeerUnsupported::ID: + return td_api::make_object(); + case telegram_api::starsTransactionPeerPremiumBot::ID: + return td_api::make_object(); + case telegram_api::starsTransactionPeerAppStore::ID: + return td_api::make_object(); + case telegram_api::starsTransactionPeerPlayMarket::ID: + return td_api::make_object(); + case telegram_api::starsTransactionPeerFragment::ID: + return td_api::make_object(); + case telegram_api::starsTransactionPeer::ID: { + DialogId dialog_id( + static_cast(transaction->peer_.get())->peer_); + if (dialog_id.get_type() == DialogType::User) { + return td_api::make_object( + td_->user_manager_->get_user_id_object(dialog_id.get_user_id(), "starTransactionSourceUser")); + } + return td_api::make_object(); + } + default: + UNREACHABLE(); + } + }(); + transactions.push_back(td_api::make_object(transaction->id_, transaction->stars_, + transaction->date_, std::move(source))); } promise_.set_value(