diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 24deb6e82..1a4ad2c91 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2518,6 +2518,9 @@ importedContacts user_ids:vector importer_count:vector = ImportedC //@macos_icon Attach menu icon for the bot in TGS format for the official native macOS app; may be null attachMenuBot bot_user_id:int53 name:string default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file = AttachMenuBot; +//@description Information about the message sent by answerWebViewQuery @inline_message_id Identifier of the sent inline message, if known +sentWebViewMessage inline_message_id:string = SentWebViewMessage; + //@description Contains an HTTP URL @url The URL httpUrl url:string = HttpUrl; @@ -4850,7 +4853,7 @@ sendWebViewData bot_user_id:int53 button_text:string data:string = Ok; //@description Sets the result of interaction with web view and sends corresponding message on behalf of the user to the chat from which the query originated; for bots only //@web_view_query_id Identifier of the web view query //@result The result of the query -answerWebViewQuery web_view_query_id:string result:InputInlineQueryResult = Ok; +answerWebViewQuery web_view_query_id:string result:InputInlineQueryResult = SentWebViewMessage; //@description Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires @chat_id Identifier of the chat with the message @message_id Identifier of the message from which the query originated @payload Query payload diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index c3fb9dafa..904ecf72b 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -193,10 +193,11 @@ class SendWebViewDataQuery final : public Td::ResultHandler { }; class SendWebViewResultMessageQuery final : public Td::ResultHandler { - Promise promise_; + Promise> promise_; public: - explicit SendWebViewResultMessageQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit SendWebViewResultMessageQuery(Promise> &&promise) + : promise_(std::move(promise)) { } void send(const string &bot_query_id, tl_object_ptr &&result) { @@ -210,8 +211,10 @@ class SendWebViewResultMessageQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - // auto ptr = result_ptr.move_as_ok(); - promise_.set_value(Unit()); + auto ptr = result_ptr.move_as_ok(); + LOG(INFO) << "Receive result for SendWebViewResultMessageQuery: " << to_string(ptr); + promise_.set_value(td_api::make_object( + InlineQueriesManager::get_inline_message_id(std::move(ptr->msg_id_)))); } void on_error(Status status) final { @@ -469,9 +472,9 @@ void InlineQueriesManager::send_web_view_data(UserId bot_user_id, string &&butto ->send(std::move(input_user), random_id, button_text, data); } -void InlineQueriesManager::answer_web_view_query(const string &web_view_query_id, - td_api::object_ptr &&input_result, - Promise &&promise) const { +void InlineQueriesManager::answer_web_view_query( + const string &web_view_query_id, td_api::object_ptr &&input_result, + Promise> &&promise) const { CHECK(td_->auth_manager_->is_bot()); TRY_RESULT_PROMISE(promise, result, get_input_bot_inline_result(std::move(input_result), nullptr, nullptr)); diff --git a/td/telegram/InlineQueriesManager.h b/td/telegram/InlineQueriesManager.h index 5d78d752a..72f438b80 100644 --- a/td/telegram/InlineQueriesManager.h +++ b/td/telegram/InlineQueriesManager.h @@ -49,7 +49,7 @@ class InlineQueriesManager final : public Actor { void answer_web_view_query(const string &web_view_query_id, td_api::object_ptr &&input_result, - Promise &&promise) const; + Promise> &&promise) const; uint64 send_inline_query(UserId bot_user_id, DialogId dialog_id, Location user_location, const string &query, const string &offset, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index d3c79dcbc..40fe82c7a 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7340,7 +7340,7 @@ void Td::on_request(uint64 id, td_api::sendWebViewData &request) { void Td::on_request(uint64 id, td_api::answerWebViewQuery &request) { CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.web_view_query_id_); - CREATE_OK_REQUEST_PROMISE(); + CREATE_REQUEST_PROMISE(); inline_queries_manager_->answer_web_view_query(request.web_view_query_id_, std::move(request.result_), std::move(promise)); }