diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7b265c6f7..4755dd169 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6942,6 +6942,12 @@ 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 Messages in a business account were deleted; for bots only +//@connection_id Unique identifier of the business connection +//@chat_id Identifier of a chat in the business account in which messages were deleted +//@message_ids Unique message identifiers of the deleted messages +updateBusinessMessagesDeleted connection_id:string chat_id:int53 message_ids:vector = 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 43f7426b6..67963e593 100644 --- a/td/telegram/BusinessConnectionManager.cpp +++ b/td/telegram/BusinessConnectionManager.cpp @@ -8,6 +8,7 @@ #include "td/telegram/AuthManager.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/DialogManager.h" #include "td/telegram/Global.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/Td.h" @@ -15,6 +16,7 @@ #include "td/telegram/telegram_api.h" #include "td/telegram/UserId.h" +#include "td/utils/format.h" #include "td/utils/logging.h" namespace td { @@ -168,6 +170,24 @@ void BusinessConnectionManager::on_update_bot_edit_business_message( td_api::make_object(connection_id.get(), std::move(message_object))); } +void BusinessConnectionManager::on_update_bot_delete_business_messages(const BusinessConnectionId &connection_id, + DialogId dialog_id, vector &&messages) { + if (!td_->auth_manager_->is_bot() || !connection_id.is_valid() || dialog_id.get_type() != DialogType::User) { + LOG(ERROR) << "Receive deletion of messages " << messages << " in " << dialog_id; + return; + } + vector message_ids; + for (auto message : messages) { + message_ids.push_back(MessageId(ServerMessageId(message)).get()); + } + td_->dialog_manager_->force_create_dialog(dialog_id, "on_update_bot_delete_business_messages", true); + send_closure( + G()->td(), &Td::send_update, + td_api::make_object( + connection_id.get(), td_->dialog_manager_->get_chat_id_object(dialog_id, "updateBusinessMessageDeleted"), + std::move(message_ids))); +} + 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 a54aae157..c420a492a 100644 --- a/td/telegram/BusinessConnectionManager.h +++ b/td/telegram/BusinessConnectionManager.h @@ -44,6 +44,9 @@ class BusinessConnectionManager final : public Actor { void on_update_bot_edit_business_message(const BusinessConnectionId &connection_id, telegram_api::object_ptr &&message); + void on_update_bot_delete_business_messages(const BusinessConnectionId &connection_id, DialogId dialog_id, + vector &&messages); + void get_business_connection(const BusinessConnectionId &connection_id, Promise> &&promise); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 255ba7777..e73f8e23e 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -3107,6 +3107,9 @@ void UpdatesManager::process_qts_update(tl_object_ptr &&up } case telegram_api::updateBotDeleteBusinessMessage::ID: { auto update = move_tl_object_as(update_ptr); + td_->business_connection_manager_->on_update_bot_delete_business_messages( + BusinessConnectionId(std::move(update->connection_id_)), DialogId(update->peer_), + std::move(update->messages_)); break; } default: