Move product_info to starTransactionSourceUser.

This commit is contained in:
levlam 2024-05-27 23:58:47 +03:00
parent 7150f71552
commit 99b3f09f07
2 changed files with 12 additions and 12 deletions

View File

@ -864,8 +864,8 @@ 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 another user @user_id Identifier of the user @product_info Information about the bought product; may be null if none
starTransactionSourceUser user_id:int53 product_info:productInfo = StarTransactionSource;
//@description The transaction is a transaction with unknown source
starTransactionSourceUnsupported = StarTransactionSource;
@ -876,8 +876,7 @@ starTransactionSourceUnsupported = StarTransactionSource;
//@star_count The amount of added owned Telegram stars; negative for outgoing transactions
//@date Point in time (Unix timestamp) when the transaction was completed
//@source Source of the transaction, or its recipient for outgoing transactions
//@product_info Information about the product; may be null if unknown
starTransaction id:string star_count:int53 date:int32 source:StarTransactionSource product_info:productInfo = StarTransaction;
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

View File

@ -681,6 +681,11 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
vector<td_api::object_ptr<td_api::starTransaction>> transactions;
for (auto &transaction : result->history_) {
td_api::object_ptr<td_api::productInfo> product_info;
if (!transaction->title_.empty() || !transaction->description_.empty() || transaction->photo_ != nullptr) {
auto photo = get_web_document_photo(td_->file_manager_.get(), std::move(transaction->photo_), DialogId());
product_info = get_product_info_object(td_, transaction->title_, transaction->description_, photo);
}
auto source = [&]() -> td_api::object_ptr<td_api::StarTransactionSource> {
switch (transaction->peer_->get_id()) {
case telegram_api::starsTransactionPeerUnsupported::ID:
@ -698,7 +703,8 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
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"));
td_->user_manager_->get_user_id_object(dialog_id.get_user_id(), "starTransactionSourceUser"),
std::move(product_info));
}
return td_api::make_object<td_api::starTransactionSourceUnsupported>();
}
@ -706,13 +712,8 @@ class GetStarsTransactionsQuery final : public Td::ResultHandler {
UNREACHABLE();
}
}();
td_api::object_ptr<td_api::productInfo> product_info;
if (!transaction->title_.empty() || !transaction->description_.empty() || transaction->photo_ != nullptr) {
auto photo = get_web_document_photo(td_->file_manager_.get(), std::move(transaction->photo_), DialogId());
product_info = get_product_info_object(td_, transaction->title_, transaction->description_, photo);
}
transactions.push_back(td_api::make_object<td_api::starTransaction>(
transaction->id_, transaction->stars_, transaction->date_, std::move(source), std::move(product_info)));
transactions.push_back(td_api::make_object<td_api::starTransaction>(transaction->id_, transaction->stars_,
transaction->date_, std::move(source)));
}
promise_.set_value(