From 26f945f2b02f25921543471c054025524b81615a Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 1 Dec 2024 00:34:48 +0300 Subject: [PATCH] Update TDLib to 1.8.41. --- td | 2 +- telegram-bot-api/Client.cpp | 155 ++++++++++++++++-------------------- telegram-bot-api/Client.h | 2 +- 3 files changed, 72 insertions(+), 87 deletions(-) diff --git a/td b/td index 66c4751..7648b99 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit 66c4751742d2ca810033b289fc57ab4f83cfc833 +Subproject commit 7648b99d81d36d44bae3ca6c514a816a2fe8cfd1 diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 3bb0d3b..641578b 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -4230,104 +4230,87 @@ class Client::JsonRevenueWithdrawalState final : public td::Jsonable { const td_api::RevenueWithdrawalState *state_; }; -class Client::JsonStarTransactionPartner final : public td::Jsonable { +class Client::JsonStarTransactionType final : public td::Jsonable { public: - JsonStarTransactionPartner(const td_api::StarTransactionPartner *source, const Client *client) - : source_(source), client_(client) { + JsonStarTransactionType(const td_api::StarTransactionType *type, const Client *client) + : type_(type), client_(client) { } + void store(td::JsonValueScope *scope) const { auto object = scope->enter_object(); - switch (source_->get_id()) { - case td_api::starTransactionPartnerFragment::ID: { - auto source_fragment = static_cast(source_); + switch (type_->get_id()) { + case td_api::starTransactionTypeFragmentDeposit::ID: object("type", "fragment"); - if (source_fragment->withdrawal_state_ != nullptr) { - object("withdrawal_state", JsonRevenueWithdrawalState(source_fragment->withdrawal_state_.get())); + break; + case td_api::starTransactionTypeFragmentWithdrawal::ID: { + auto type = static_cast(type_); + object("type", "fragment"); + if (type->withdrawal_state_ != nullptr) { + object("withdrawal_state", JsonRevenueWithdrawalState(type->withdrawal_state_.get())); } break; } - case td_api::starTransactionPartnerBot::ID: { - auto source_user = static_cast(source_); + case td_api::starTransactionTypeBotPaidMediaSale::ID: { + auto type = static_cast(type_); object("type", "user"); - object("user", JsonUser(source_user->user_id_, client_)); - CHECK(source_user->purpose_ != nullptr); - switch (source_user->purpose_->get_id()) { - case td_api::botTransactionPurposeInvoicePayment::ID: { - auto purpose = - static_cast(source_user->purpose_.get()); - if (!purpose->invoice_payload_.empty()) { - if (!td::check_utf8(purpose->invoice_payload_)) { - LOG(WARNING) << "Receive non-UTF-8 invoice payload"; - object("invoice_payload", td::JsonRawString(purpose->invoice_payload_)); - } else { - object("invoice_payload", purpose->invoice_payload_); - } - } - break; - } - case td_api::botTransactionPurposePaidMedia::ID: { - auto purpose = static_cast(source_user->purpose_.get()); - object("paid_media", td::json_array(purpose->media_, [client = client_](auto &media) { - return JsonPaidMedia(media.get(), client); - })); - if (!purpose->payload_.empty()) { - object("paid_media_payload", purpose->payload_); - } - break; - } - case td_api::botTransactionPurposeSubscription::ID: { - auto purpose = static_cast(source_user->purpose_.get()); - if (!purpose->invoice_payload_.empty()) { - if (!td::check_utf8(purpose->invoice_payload_)) { - LOG(WARNING) << "Receive non-UTF-8 invoice payload"; - object("invoice_payload", td::JsonRawString(purpose->invoice_payload_)); - } else { - object("invoice_payload", purpose->invoice_payload_); - } - } - if (purpose->period_ > 0) { - object("subscription_period", purpose->period_); - } - break; - } - default: - UNREACHABLE(); + object("user", JsonUser(type->user_id_, client_)); + object("paid_media", td::json_array(type->media_, [client = client_](auto &media) { + return JsonPaidMedia(media.get(), client); + })); + if (!type->payload_.empty()) { + object("paid_media_payload", type->payload_); } break; } - case td_api::starTransactionPartnerTelegramAds::ID: + case td_api::starTransactionTypeBotInvoiceSale::ID: { + auto type = static_cast(type_); + object("type", "user"); + object("user", JsonUser(type->user_id_, client_)); + if (!type->invoice_payload_.empty()) { + if (!td::check_utf8(type->invoice_payload_)) { + LOG(WARNING) << "Receive non-UTF-8 invoice payload"; + object("invoice_payload", td::JsonRawString(type->invoice_payload_)); + } else { + object("invoice_payload", type->invoice_payload_); + } + } + break; + } + case td_api::starTransactionTypeBotSubscriptionSale::ID: { + auto type = static_cast(type_); + object("type", "user"); + object("user", JsonUser(type->user_id_, client_)); + if (!type->invoice_payload_.empty()) { + if (!td::check_utf8(type->invoice_payload_)) { + LOG(WARNING) << "Receive non-UTF-8 invoice payload"; + object("invoice_payload", td::JsonRawString(type->invoice_payload_)); + } else { + object("invoice_payload", type->invoice_payload_); + } + } + if (type->subscription_period_ > 0) { + object("subscription_period", type->subscription_period_); + } + break; + } + case td_api::starTransactionTypeTelegramAdsWithdrawal::ID: object("type", "telegram_ads"); break; - case td_api::starTransactionPartnerTelegramApi::ID: { - auto source = static_cast(source_); + case td_api::starTransactionTypeTelegramApiUsage::ID: { + auto type = static_cast(type_); object("type", "telegram_api"); - object("request_count", source->request_count_); + object("request_count", type->request_count_); break; } - case td_api::starTransactionPartnerUser::ID: { - auto source = static_cast(source_); - if (source->purpose_->get_id() == td_api::userTransactionPurposeGiftSend::ID) { - object("type", "user"); - object("user", JsonUser(source->user_id_, client_)); - object( - "gift", - JsonGift(static_cast(source->purpose_.get())->gift_.get(), - client_)); - } else { - LOG(ERROR) << "Receive " << to_string(*source_); - object("type", "other"); - } + case td_api::starTransactionTypeGiftPurchase::ID: { + auto type = static_cast(type_); + object("type", "user"); + object("user", JsonUser(type->user_id_, client_)); + object("gift", JsonGift(type->gift_.get(), client_)); break; } - case td_api::starTransactionPartnerTelegram::ID: - case td_api::starTransactionPartnerAppStore::ID: - case td_api::starTransactionPartnerGooglePlay::ID: - case td_api::starTransactionPartnerBusiness::ID: - case td_api::starTransactionPartnerChat::ID: - LOG(ERROR) << "Receive " << to_string(*source_); - object("type", "other"); - break; - case td_api::starTransactionPartnerUnsupported::ID: + case td_api::starTransactionTypeAffiliateProgramCommission::ID: + case td_api::starTransactionTypeUnsupported::ID: object("type", "other"); break; default: @@ -4336,7 +4319,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { } private: - const td_api::StarTransactionPartner *source_; + const td_api::StarTransactionType *type_; const Client *client_; }; @@ -4349,12 +4332,14 @@ class Client::JsonStarTransaction final : public td::Jsonable { auto object = scope->enter_object(); object("id", transaction_->id_); object("date", transaction_->date_); - if (transaction_->star_count_ > 0) { - object("amount", transaction_->star_count_); - object("source", JsonStarTransactionPartner(transaction_->partner_.get(), client_)); + auto star_count = transaction_->star_amount_->star_count_; + auto nanostar_count = transaction_->star_amount_->nanostar_count_; + if (star_count > 0 || nanostar_count > 0) { + object("amount", star_count); + object("source", JsonStarTransactionType(transaction_->type_.get(), client_)); } else { - object("amount", -transaction_->star_count_); - object("receiver", JsonStarTransactionPartner(transaction_->partner_.get(), client_)); + object("amount", -star_count); + object("receiver", JsonStarTransactionType(transaction_->type_.get(), client_)); } } diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 500995a..6b04b19 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -204,7 +204,7 @@ class Client final : public WebhookActor::Callback { class JsonGiveawayCompleted; class JsonChatBoostAdded; class JsonRevenueWithdrawalState; - class JsonStarTransactionPartner; + class JsonStarTransactionType; class JsonStarTransaction; class JsonStarTransactions; class JsonUpdateTypes;