From baa7fe85983dc0be97111c932c7f8958827d2e9a Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 5 Apr 2024 15:59:54 +0300 Subject: [PATCH] Add td_api::ChatRevenueWithdrawalState. --- td/generate/scheme/td_api.tl | 23 +++++++++++++++++------ td/telegram/StatisticsManager.cpp | 17 ++++++++++++++--- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 509801e28..d46ce0727 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6599,6 +6599,20 @@ messageStatistics message_interaction_graph:StatisticalGraph message_reaction_gr storyStatistics story_interaction_graph:StatisticalGraph story_reaction_graph:StatisticalGraph = StoryStatistics; +//@class ChatRevenueWithdrawalState @description Describes state of a chat revenue withdrawal + +//@description Withdrawal is pending +chatRevenueWithdrawalStatePending = ChatRevenueWithdrawalState; + +//@description Withdrawal was completed +//@date Point in time (Unix timestamp) when the withdrawal was completed +//@url The URL where the withdrawal transaction can be viewed +chatRevenueWithdrawalStateCompleted date:int32 url:string = ChatRevenueWithdrawalState; + +//@description Withdrawal has_failed +chatRevenueWithdrawalStateFailed = ChatRevenueWithdrawalState; + + //@class ChatRevenueTransactionType @description Describes type of a transaction for revenue earned from sponsored messages in a chat //@description Describes earnings from sponsored messages in a chat in some time frame @@ -6607,13 +6621,10 @@ storyStatistics story_interaction_graph:StatisticalGraph story_reaction_graph:St chatRevenueTransactionTypeEarnings start_date:int32 end_date:int32 = ChatRevenueTransactionType; //@description Describes a withdrawal of earnings -//@withdrawal_date Point in time (Unix timestamp) when the earnings were withdrawn -//@is_pending True, if the transaction didn't complete yet -//@is_failed True, if the transaction has failed +//@withdrawal_date Point in time (Unix timestamp) when the earnings withdrawal started //@provider Name of the payment provider -//@transaction_date Point in time (Unix timestamp) when the withdrawal was completed; 0 if none -//@transaction_url The URL where the transaction can be viewed; empty if none -chatRevenueTransactionTypeWithdrawal withdrawal_date:int32 is_pending:Bool is_failed:Bool provider:string transaction_date:int32 transaction_url:string = ChatRevenueTransactionType; +//@state State of the withdrawal +chatRevenueTransactionTypeWithdrawal withdrawal_date:int32 provider:string state:ChatRevenueWithdrawalState = ChatRevenueTransactionType; //@description Describes a refund for failed withdrawal of earnings //@refund_date Point in time (Unix timestamp) when the transaction was refunded diff --git a/td/telegram/StatisticsManager.cpp b/td/telegram/StatisticsManager.cpp index 50655b9be..730671be4 100644 --- a/td/telegram/StatisticsManager.cpp +++ b/td/telegram/StatisticsManager.cpp @@ -373,16 +373,27 @@ class GetBroadcastRevenueTransactionsQuery final : public Td::ResultHandler { auto transaction = telegram_api::move_object_as(transaction_ptr); amount = get_amount(transaction->amount_, true); + auto state = [&]() -> td_api::object_ptr { + if (transaction->transaction_date_ > 0) { + return td_api::make_object(); + } + if (transaction->pending_) { + return td_api::make_object(); + } + if (!transaction->failed_) { + LOG(ERROR) << "Transaction has unknown state"; + } + return td_api::make_object(); + }(); return td_api::make_object( - transaction->date_, transaction->pending_, transaction->failed_, transaction->provider_, - transaction->transaction_date_, transaction->transaction_url_); + transaction->date_, transaction->provider_, std::move(state)); } case telegram_api::broadcastRevenueTransactionRefund::ID: { auto transaction = telegram_api::move_object_as(transaction_ptr); amount = get_amount(transaction->amount_); return td_api::make_object(transaction->date_, - transaction->provider_); + transaction->provider_); } default: UNREACHABLE();