From bcceb9f623cf73a7c6538a9dddb10ca5c6f6622d Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 9 Mar 2024 02:17:00 +0300 Subject: [PATCH] Add td_api::updateBusinessMessageEdited. --- td/generate/scheme/td_api.tl | 5 ++++- td/telegram/BusinessConnectionManager.cpp | 15 +++++++++++++++ td/telegram/BusinessConnectionManager.h | 3 +++ td/telegram/UpdatesManager.cpp | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 5bd8ab638..a55a75627 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6935,9 +6935,12 @@ updateAutosaveSettings scope:AutosaveSettingsScope settings:scopeAutosaveSetting //@description A business connection has changed; for bots only @connection New data about the connection updateBusinessConnection connection:businessConnection = Update; -//@description A new message was added to a business account; for bots only @connection_id Unique identifier of the connection @message The new message +//@description A new message was added to a business account; for bots only @connection_id Unique identifier of the business connection @message The new message updateNewBusinessMessage connection_id:string message:message = Update; +//@description A message in a business account was edited; for bots only @connection_id Unique identifier of the business connection @message The edited message +updateBusinessMessageEdited connection_id:string message:message = Update; + //@description A new incoming inline query; for bots only //@id Unique query identifier //@sender_user_id Identifier of the user who sent the query diff --git a/td/telegram/BusinessConnectionManager.cpp b/td/telegram/BusinessConnectionManager.cpp index ce8e40f09..43f7426b6 100644 --- a/td/telegram/BusinessConnectionManager.cpp +++ b/td/telegram/BusinessConnectionManager.cpp @@ -153,6 +153,21 @@ void BusinessConnectionManager::on_update_bot_new_business_message( td_api::make_object(connection_id.get(), std::move(message_object))); } +void BusinessConnectionManager::on_update_bot_edit_business_message( + const BusinessConnectionId &connection_id, telegram_api::object_ptr &&message) { + if (!td_->auth_manager_->is_bot() || !connection_id.is_valid()) { + LOG(ERROR) << "Receive " << to_string(message); + return; + } + auto message_object = td_->messages_manager_->get_business_message_object(std::move(message)); + if (message_object == nullptr) { + return; + } + send_closure( + G()->td(), &Td::send_update, + td_api::make_object(connection_id.get(), std::move(message_object))); +} + void BusinessConnectionManager::get_business_connection( const BusinessConnectionId &connection_id, Promise> &&promise) { auto connection = business_connections_.get_pointer(connection_id); diff --git a/td/telegram/BusinessConnectionManager.h b/td/telegram/BusinessConnectionManager.h index fdee9ca99..a54aae157 100644 --- a/td/telegram/BusinessConnectionManager.h +++ b/td/telegram/BusinessConnectionManager.h @@ -41,6 +41,9 @@ class BusinessConnectionManager final : public Actor { void on_update_bot_new_business_message(const BusinessConnectionId &connection_id, telegram_api::object_ptr &&message); + void on_update_bot_edit_business_message(const BusinessConnectionId &connection_id, + telegram_api::object_ptr &&message); + void get_business_connection(const BusinessConnectionId &connection_id, Promise> &&promise); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 3e52e50e0..255ba7777 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -3101,6 +3101,8 @@ void UpdatesManager::process_qts_update(tl_object_ptr &&up } case telegram_api::updateBotEditBusinessMessage::ID: { auto update = move_tl_object_as(update_ptr); + td_->business_connection_manager_->on_update_bot_edit_business_message( + BusinessConnectionId(std::move(update->connection_id_)), std::move(update->message_)); break; } case telegram_api::updateBotDeleteBusinessMessage::ID: {