diff --git a/td/telegram/BusinessConnectionManager.cpp b/td/telegram/BusinessConnectionManager.cpp index d57a19208..898dc51ab 100644 --- a/td/telegram/BusinessConnectionManager.cpp +++ b/td/telegram/BusinessConnectionManager.cpp @@ -309,7 +309,7 @@ class BusinessConnectionManager::SendBusinessMultiMediaQuery final : public Td:: auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendBusinessMultiMediaQuery: " << to_string(ptr); - promise_.set_value(nullptr); // TODO + td_->business_connection_manager_->process_sent_business_message_album(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -1078,4 +1078,30 @@ void BusinessConnectionManager::on_upload_message_album_media(int64 request_id, ->send(std::move(messages), std::move(input_single_media)); } +void BusinessConnectionManager::process_sent_business_message_album( + telegram_api::object_ptr &&updates_ptr, + Promise> &&promise) { + if (updates_ptr->get_id() != telegram_api::updates::ID) { + LOG(ERROR) << "Receive " << to_string(updates_ptr); + return promise.set_error(Status::Error(500, "Receive invalid business connection messages")); + } + auto updates = telegram_api::move_object_as(updates_ptr); + for (auto &update : updates->updates_) { + if (update->get_id() != telegram_api::updateBotNewBusinessMessage::ID) { + LOG(ERROR) << "Receive " << to_string(updates); + return promise.set_error(Status::Error(500, "Receive invalid business connection messages")); + } + } + td_->contacts_manager_->on_get_users(std::move(updates->users_), "SendBusinessMediaQuery"); + td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "SendBusinessMediaQuery"); + + auto messages = td_api::make_object(); + for (auto &update_ptr : updates->updates_) { + auto update = telegram_api::move_object_as(update_ptr); + messages->messages_.push_back(td_->messages_manager_->get_business_message_object( + std::move(update->message_), std::move(update->reply_to_message_))); + } + promise.set_value(std::move(messages)); +} + } // namespace td diff --git a/td/telegram/BusinessConnectionManager.h b/td/telegram/BusinessConnectionManager.h index 1aad44839..435dd5302 100644 --- a/td/telegram/BusinessConnectionManager.h +++ b/td/telegram/BusinessConnectionManager.h @@ -152,6 +152,9 @@ class BusinessConnectionManager final : public Actor { void on_upload_message_album_media(int64 request_id, size_t media_pos, Result &&result); + void process_sent_business_message_album(telegram_api::object_ptr &&updates_ptr, + Promise> &&promise); + WaitFreeHashMap, BusinessConnectionIdHash> business_connections_; FlatHashMap>>,