Add new revenue amount to updateChatRevenueAmount.

This commit is contained in:
levlam 2024-05-07 13:45:35 +03:00
parent 22ebe2c7bf
commit 571f0b445a
4 changed files with 20 additions and 5 deletions

View File

@ -7237,7 +7237,9 @@ updateDefaultReactionType reaction_type:ReactionType = Update;
updateSavedMessagesTags saved_messages_topic_id:int53 tags:savedMessagesTags = Update;
//@description The revenue earned from sponsored messages in a chat has changed. If chat revenue screen is opened, then getChatRevenueTransactions may be called to fetch new transactions
updateChatRevenueAmount = Update;
//@chat_id Identifier of the chat
//@revenue_amount New amount of earned revenue
updateChatRevenueAmount chat_id:int53 revenue_amount:chatRevenueAmount = Update;
//@description The parameters of speech recognition without Telegram Premium subscription has changed
//@max_media_duration The maximum allowed duration of media for speech recognition without Telegram Premium subscription, in seconds

View File

@ -698,8 +698,19 @@ void StatisticsManager::get_channel_revenue_statistics(
}
void StatisticsManager::on_update_dialog_revenue_transactions(
telegram_api::object_ptr<telegram_api::broadcastRevenueBalances> balances) {
send_closure(G()->td(), &Td::send_update, td_api::make_object<td_api::updateChatRevenueAmount>());
DialogId dialog_id, telegram_api::object_ptr<telegram_api::broadcastRevenueBalances> balances) {
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive updateBroadcastRevenueTransactions in invalid " << dialog_id;
return;
}
if (!td_->messages_manager_->have_dialog(dialog_id)) {
LOG(INFO) << "Ignore unnneeded updateBroadcastRevenueTransactions in " << dialog_id;
return;
}
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatRevenueAmount>(
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateChatRevenueAmount"),
convert_broadcast_revenue_balances(std::move(balances))));
}
void StatisticsManager::get_channel_revenue_withdrawal_url(DialogId dialog_id, const string &password,

View File

@ -38,7 +38,8 @@ class StatisticsManager final : public Actor {
void get_channel_revenue_transactions(DialogId dialog_id, int32 offset, int32 limit,
Promise<td_api::object_ptr<td_api::chatRevenueTransactions>> &&promise);
void on_update_dialog_revenue_transactions(telegram_api::object_ptr<telegram_api::broadcastRevenueBalances> balances);
void on_update_dialog_revenue_transactions(DialogId dialog_id,
telegram_api::object_ptr<telegram_api::broadcastRevenueBalances> balances);
void get_channel_message_statistics(MessageFullId message_full_id, bool is_dark,
Promise<td_api::object_ptr<td_api::messageStatistics>> &&promise);

View File

@ -4554,7 +4554,8 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotDeleteBusine
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBroadcastRevenueTransactions> update,
Promise<Unit> &&promise) {
td_->statistics_manager_->on_update_dialog_revenue_transactions(std::move(update->balances_));
td_->statistics_manager_->on_update_dialog_revenue_transactions(DialogId(update->peer_),
std::move(update->balances_));
promise.set_value(Unit());
}