Add td_api::StarTransactionSource.
This commit is contained in:
parent
20605f5908
commit
b6f1a2e195
@ -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
|
||||
|
@ -679,8 +679,33 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
|
||||
|
||||
vector<td_api::object_ptr<td_api::starTransaction>> transactions;
|
||||
for (auto &transaction : result->history_) {
|
||||
transactions.push_back(
|
||||
td_api::make_object<td_api::starTransaction>(transaction->id_, transaction->stars_, transaction->date_));
|
||||
auto source = [&]() -> td_api::object_ptr<td_api::StarTransactionSource> {
|
||||
switch (transaction->peer_->get_id()) {
|
||||
case telegram_api::starsTransactionPeerUnsupported::ID:
|
||||
return td_api::make_object<td_api::starTransactionSourceUnsupported>();
|
||||
case telegram_api::starsTransactionPeerPremiumBot::ID:
|
||||
return td_api::make_object<td_api::starTransactionSourceTelegram>();
|
||||
case telegram_api::starsTransactionPeerAppStore::ID:
|
||||
return td_api::make_object<td_api::starTransactionSourceAppStore>();
|
||||
case telegram_api::starsTransactionPeerPlayMarket::ID:
|
||||
return td_api::make_object<td_api::starTransactionSourceGooglePlay>();
|
||||
case telegram_api::starsTransactionPeerFragment::ID:
|
||||
return td_api::make_object<td_api::starTransactionSourceFragment>();
|
||||
case telegram_api::starsTransactionPeer::ID: {
|
||||
DialogId dialog_id(
|
||||
static_cast<const telegram_api::starsTransactionPeer *>(transaction->peer_.get())->peer_);
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
return td_api::make_object<td_api::starTransactionSourceUser>(
|
||||
td_->user_manager_->get_user_id_object(dialog_id.get_user_id(), "starTransactionSourceUser"));
|
||||
}
|
||||
return td_api::make_object<td_api::starTransactionSourceUnsupported>();
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}();
|
||||
transactions.push_back(td_api::make_object<td_api::starTransaction>(transaction->id_, transaction->stars_,
|
||||
transaction->date_, std::move(source)));
|
||||
}
|
||||
|
||||
promise_.set_value(
|
||||
|
Loading…
Reference in New Issue
Block a user